Useful Git Cheat Sheet
Configure name that is identifiable for credit when reviewing version history
# git config –global user.name “<FIRST AND LAST NAME>”
Configure email that will be associated with each history marker
# git config –global user.email “EMAIL-ADDRESS”
Set automatic command line coloring for Git – for easy reviewing
# git config –global color.ui auto
Initializing an existing directly as Git repository or create a new local repo
# git init
Clone existing repo from hosted location on local machine via URL
# git clone <REPO-URL>
Clone specific branch from hosted location
#git clone -b <branch-name> <REPO-URL> <FOLDER_NAME>
Show modified files in working directory (staged for next commit)
# git status
Add a file to your next commit
# git add <FILE>
Add all changes/files to commit
# git add.
Add some changes/file to commit
# git add -p <file>
Check difference of what is changed (but not staged)
# git diff
Check difference of what is staged (but not committed)
# git diff –staged
Commit all local changes or staged content as a new commit snapshot
# git commit –m “<your comment>”
Check current branch name
# git branch
Check all branches
# git branch –av
Create a new branch at the current commit
# git branch <branch-name>
Delete a local branch
# git branch –d <branch-name>
Create and switch to a new branch
# git checkout -b <branch-name>
Merge specified branch history into current
# git merge <branch-name>
Check all commits history in the current active branch
# git log
Check log for any file
# git log –p <file>Show all commits on “branch-prod” that are not on “branch-dev”
# git log <branch-dev>..<branch-prod>
Show difference of what is on “branch-prod” that are not on “branch-dev”
# git diff <branch-dev>..<branch-prod>
Check all configured remotes
# git remote –v
Check info about any remote repo
# git remote show <remote-repo>
Fetch and merge any commits from remote branch
# git pull <remote-repo> <branch-name>
Push your local branch commits to remote branch
# git push origin <branch-name>
Push/upload local changes to remote branch
# git push <remote-repo> <branch-name>
Push/upload local changes to remote branch
# git push <remote-repo> <branch-name>
Push/upload local changes to remote branch
# git push <remote-repo> <branch-name>
Delete the file from the project and stage removal from the commit
# git rm <FILE>
Apply any commits of a current branch ahead of specified
# git rebase <branch-name>
Revert a commit
# git revert <commit>
Un-stage a file while retaining changes in the working directory
# git reset <FILE>
Save modified and staged changes
# git stash
List stack order of stashed file changes
# git stash list
Ready to Solve Your Most Complex Technical Challenges?
Our senior advisors are ready to help you navigate the ever-evolving technology landscape with precision and expertise.
Schedule a ConsultationRelated Articles
GDPR: General Data Protection Regulation
The European Union’s General Data Protection Regulation on data privacy came into effect on May 25, 2018. This new regulation policy applies…
Install Zoom on Ubuntu
You can install Zoom on Ubuntu in two ways: 1. Installing through Ubuntu Software install Firstly, we need to download the Zoom…
Steps for the Effective Application Development Process
Step 1: THE IDEA Assist customers with creating and building their unique idea. Share suggestions to the client and answer inquiries about…