Cheat SheetsTopics

Git Commands

Knowledge of version control systems are a mandatory skill set for developers.

Git is among the most popular.

It is a is a free and open source distributed version control system designed to handle any size software development project, however, it can also keep track of changes to any type of files.

If you want to create your own remote Git repositories you might want to check out and Both are great services and with bitbucket, you can also create private repositories.

So that being said I thought it might be a good idea to keep a list of most common commands (obviously a subjective POV).


Git commands

Working tree status:


Stage changes all for commit:


Commit changes to the local repository:


Push changes to the remote repository:


Updates local repository with branches and/or tags along with the objects necessary to complete their histories:  


Fetch and integrate with another repository or a local branch: 


List local branches:


List both remote-tracking branches and local branches:


Create a branch in local repository:


Create a branch in the local repository and switch to the new branch:


Push branch from the local repository to the remote repository:


Show remote branches


Delete local branch


Delete remote branch:


Rename local branch:


Rename remote branch:

1. Rename local branch: 

2. Delete remote branch: 

3. Push the new branch, set local branch to track the new remote:


Switch branch:


Fetch remote branch


Pull remote branch


List tags:


Create annotated tag:


Remove file from repository and file system:


Remove file only from the repository, but not file system:


How to merge a branch into another branch:

1. Save your changes:


2. Check out the branch you want to be merged into your current branch

3. Update branch, if needed:

4. Go back to your original branch:

5. Merge:


Save your local modifications and reverts the working directory to match the HEAD commit:


Save your local modifications, including untracked files, and reverts the working directory to match the HEAD commit:


Remove a single stashed state from the stash list and apply it on top of the current working tree state:


View stashed files:


Clear stashed files:


Rename a tag


Move date for the selected commit to the index (staging area) and the working area:

working area <– index <– repository


Moves date for the selected commit to the index (staging area) but not the working area (this is the default option of reset):

index <– repository


Move the branch to the selected commit, and do not touch the index and working area:


Unstage a file (similar to git reset –mixed <SOME-COMMIT>), modifies only the index (staging) area:


Unstage a file (similar to git reset –hard<SOME-COMMIT>), modifies the index and the working area (use with care, this is a destructive operation):



To be continued…

Spread the knowledge

Leave a Reply

Your email address will not be published. Required fields are marked *