Posts Git Cheatsheet
Post
Cancel

Git Cheatsheet

Deleting last commits

1
2
3
4
5
6
7
8
9
# Remove last 2 commits with its changes; where HEAD^ last commit from the top

$ git reset --hard HEAD^2

# Remove last commit with working tree around (Remove --hard); where HEAD^ counts from last commit

$ git reset HEAD^

Git checkout with remote branch updates

1
2
3
$ git remote update
$ git fetch
$ git checkout --track origin/<BRANCH-NAME>

Delete remote branch

1
$ git push <remote_name> --delete <branch_name>

Git untrack file or a folder

1
$ git rm -r --cached path_to_your_folder/

Rename branch git

https://multiplestates.wordpress.com/2015/02/05/rename-a-local-and-remote-branch-in-git/

Git Flow

https://danielkummer.github.io/git-flow-cheatsheet/

This post is licensed under CC BY 4.0 by the author.