Skip to content

Instantly share code, notes, and snippets.

@farskid
Last active February 4, 2020 13:16
Show Gist options
  • Save farskid/a7124ee7018a4a8088ac65d3474dcb1c to your computer and use it in GitHub Desktop.
Save farskid/a7124ee7018a4a8088ac65d3474dcb1c to your computer and use it in GitHub Desktop.
Useful git tips, aliases and configs
# Set upstream automatically on `git push`
`git config --global push.default current`
## The reference to the last branch is saved into `-` in git.
# Checkout to the previous branch
`git checkout -`
# Merge into the last branch
`git merge -`
# See the diff of two branches
## Diff against their heads
`git diff branch_1..branch_2`
## Diff against their common ancestor
`git diff branch_1...branch_2`
# See contents of a stash without applying it
`git stash show -p stash@{1}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment