My Git cheat sheet

Despina Papatheodorou
2 min readApr 12, 2021


Git is the most commonly used version control system used among developers. No need to mention its advantages, you can google them!

But, let’s admit it, all developers who love Git, have faced (or still face) difficulties with it and even the most experienced of them keep a cheat sheet to make their life easier.

Excellent practice!

In this post, I would like to share my git-cheat-sheet with the most common commands that I use in my dev-life and I hope to find it useful!

Let’s assume that you have 2 branches : Master and Develop

New Branch Creation

Assume that you have opened the terminal inside a git versioned folder

git fetch --all
git pull

Now the current branch is updated

git checkout -b <Branch>

The new branch is created from the current , this is why we update the current branch

git push origin <Branch>
git checkout -b <branch> <sha>

Creates a new branch from a commit <sha>

git checkout -b newBranch origin/develop

New branch is created from origin/develop

Push branch on Remote Repository (Git Server)

git push origin <Branch>
git push --force

Commit Changes & Push

git add <file_url>
git commit -m “message here”
git push

Delete old branches

git branch -a

Shows all your branches

git remote prune origin

Deletes the remote branches that have been deleted

git branch -D <branch>

Deletes <branch>


git fetch --allgit stash //stash your local changes (if you have any)git checkout master
git pull
git checkout develop
git rebase master
git push — force //push the rebased changes on origingit stash pop //pop your local changes back


git reset --hard HEADgit fetch origin
git reset --hard origin/develop
git checkout -B develop origin/develop
//Resets develop branch to origin/develop , if develop branch was existed on your local

Merge Develop Into Master

git fetch --allgit checkout developgit pullgit checkout mastergit pullgit merge — no-ff develop 
//merges develop into current branch (master) without fast-forward
git push origin