Skip to content

Instantly share code, notes, and snippets.

Last active September 25, 2017 17:03
What would you like to do?
GIT Cheat Sheet

Git Cheat Sheet


Delete remote branch: git push origin :<branchName>

Add a remote branch: git remote add <remoteName> <gitAddress>

Remove local branches that are no longer on origin: git fetch --prune

Add remote to existing local rep, and track master: git remote add --track master origin


Showing remotes: git remote -v

Set remote repo: git remote set-url origin

Revert and Undo

Undo previous commit: git revert HEAD^

Modify previous commit message: git commit --amend

Reset to the most recent commit git reset --hard


Temporarily stash changes: git stash

Restore changes from stash: git stash pop

Delete changes in stash: git stash drop


Show status with list modified/new/etc files: git status -s


Add a new submodule: git submodule add git@mygithost:repo path/to/dir

Update all the submodules (externals): git submodule update --init --recursive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment