Git Cheat Sheet¶
This page contains a list of commonly used git
commands and flags.
Basic command¶
Creation of a new local repo
git init
User and email configuration
git config --global user.email sam@google.com
Adding modified files for the next commit
git add 'file-name' or '.' for all file
Create a commit
git commit -m 'Your message'
Information on the status of the current branch
git status
View file changes
git diff
Publish local changes to the git server
git push origin master
List the local branches
git branch
List the server branches (remote)
git branch -r
List the local and server branches (all)
git branch -a
Tilt of branch
git checkout 'Branch-name'
Create a branche
git checkout -b 'NAME'
Delete a branch (delete)
git branch -d 'name'
To merge all the modifications present on the remote repository into the local working directory (to be used before pushing the local modifications to avoid conflicts if another person has made modifications)
git pull
git merge 'branch-name'
Useful links¶
You can find above a list of basic commands to use git but there are many more options depending on your needs. Here are some websites to learn more :