Git Cheat Sheet

Branching

Command
Deleting a local branch git branch -d {branch}
Deleting a remote branch git push origin --delete {branch}

Logs

Command
List commit count by user git shortlog -s -n

Reverting Files

Command
Revert changes to modified files git reset --hard
Revert to tag, branch, or previous version (rollback) git reset --hard {tag/branch/commit id}
Remove all untracked files and directories git clean -fd

Stashing

Command
Stash current changes git stash
Stash current changes with name git stash save "{Name}"
Stash current changes with untracked/unstaged files git stash -u
Stash current changes with untracked/unstaged files and a name git stash save -u "{Name}"
Listing stashes (Note: type ":q" to exit) git stash list
Applying the last set of stashed changes git stash apply

Other

Command
Removing files git rm -r --cached --ignore-unmatch {file/dir}