Skip to content

Instantly share code, notes, and snippets.

@alexcreek
Last active December 18, 2021 03:08
Show Gist options
  • Save alexcreek/704bb040626e44c1a88dc2d38693d125 to your computer and use it in GitHub Desktop.
Save alexcreek/704bb040626e44c1a88dc2d38693d125 to your computer and use it in GitHub Desktop.
git cheat sheet

Show me all commits since the previous tag option 1 - hard mode

git --no-pager log --oneline --no-merges --decorate=no $(git describe --tags --abbrev=0)..

Show me all commits since the previous tag option 2 - ez mode

# with git-extras installed https://github.com/tj/git-extras
# update the changlog format first 
git config changelog.format "%h %s"
git changelog -n -l -x
git changelog --no-merges --list --stdout # long-form

Show the current commit's short hash

git rev-parse --short HEAD

Show the current branch's name

git rev-parse --abbrev-ref HEAD

Show what branch a commit belongs to

git name-rev --name-only $commit

Stop tracking a file in git

git rm --cached $file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment