# setting global Git Username and Email
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --list
# The command saves the values in the global configuration file, ~/.gitconfig
# If you want to use a different username or email address for a specific repository, run the git config command without the --global option from within the repository directory
# view all remote
git remote -v
# view local branches:
git branch
# view remote branches:
git branch -r
# change remote origin
git remote set-url <remote_name> <remote_url>
#git remote set-url origin https://git-repo/new-repository.git
#git remote set-url upstream https://git-repo/new-repository.git
# view all local and remote branches:
git branch -a
# switch branch
git checkout <existing_branch>
# create new branch
git checkout -b <new_branch>
# push to branch
git push --set-upstream origin <your branch name>
# List all files in <branch>
git checkout <branch>
git ls-files
# once you switch to local branch then:
git pull origin "branchname" #this pulls all content(files/folders) from remote
#display all commit s with id
git log
# Switch to the main branch
git checkout main
# Merge the current branch to the main branch and squash the changes into a single commit
git merge --squash <branch-name>
# Review and stage the changes
git add .
# Commit the changes with a meaningful commit message
git commit -m "Merge <branch-name> to main"
# Push the merged changes to the remote repository
git push origin main
To git ignore a folder: https://stackoverflow.com/a/28346487/7677793 create the ".gitignore" file with the contents:
*
!.gitignore