Skip to content

Instantly share code, notes, and snippets.

@seansean11
Forked from jaredkc/git-cheat-sheet.md
Last active December 20, 2015 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seansean11/6153177 to your computer and use it in GitHub Desktop.
Save seansean11/6153177 to your computer and use it in GitHub Desktop.
Undo previous commit
`git revert HEAD^`
Modify previous commit message
`git commit --amend`
Temporarily stash changes
`git stash`
Restore changes from stash
`git stash pop`
Delete changes in stash
`git stash drop`
Delete all stashes
`git stash clear`
Delete remote branch
`git push origin :<branchName>`
Add a remote branch
`git remote add <remoteName> <gitAddress>`
Add a new submodule
`git submodule add git@mygithost:repo path/to/dir`
Update all the submodules (externals)
`git submodule update --init --recursive`
Equivalent of svn revert, default is "HEAD"
`git reset --hard`
Show status with list modified/new/etc files
`git status -s`
Add remote to existing local rep, and track master
`git remote add --track master origin git@github.com:abc/123.git`
Show a single line log
`git log --singleline`
Rewind head to replay your work on top of it
`git rebase <branchName>`
Alter commits on current branch (interactive rebase)
`git rebase -i HEAD~<number>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment