Git Cheat Sheet
Branches
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 git@github.com:abc/123.git
Remotes
Showing remotes:
git remote -v
Set remote repo:
git remote set-url origin git@github.com:account/whatever.git
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
Stash
Temporarily stash changes:
git stash
Restore changes from stash:
git stash pop
Delete changes in stash:
git stash drop
Status
Show status with list modified/new/etc files:
git status -s
Submodules
Add a new submodule:
git submodule add git@mygithost:repo path/to/dir
Update all the submodules (externals):
git submodule update --init --recursive