undo merge that hasn't been pushed

git reset --merge HEAD~1

roll back hard

git reset --hard <commit/tag>

force push of a previous commit

git push -f origin <commit_id>:<branch>

delete remote branch

git push --delete origin <branch>

reset local branch after a forced-update (above)

git fetch
git reset origin/<branch> --hard

renaming branch and updating remote

git branch -m old-name new-name
git push origin --set-upstream new-name
git push origin :old-name

set username for single repo

git config user.username 'name'

set signing key for local repo

git config user.signingkey <id>

signing commits

git commit -S -m 'msg'

compare diff between two commits

git diff <commit>...<commit>


git stash
git stash show


git stash pop

add remote origin

git remote add origin git@gitserver/path/to/repo

add multiple push repos

git remote set-url --add --push origin git@gitserver/original/repo
git remote set-url --add --push origin https://gitserver/another/repo

archive branch

git archive --format zip --outpu /path/to/output.zip <branch>

using hub

pull requests

hub pr list
hub pr checkout <num>

helpful links

making a pull request

branching and rebasing

branching model

merging and rebasing