Skip to content

Instantly share code, notes, and snippets.

@cmackenzie1
Created February 6, 2024 19:28
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 cmackenzie1/7743a88eb95fef330d45a0f37b145f17 to your computer and use it in GitHub Desktop.
Save cmackenzie1/7743a88eb95fef330d45a0f37b145f17 to your computer and use it in GitHub Desktop.
My favorite git commands

Copy last commit message to clipboard

git log -1 --pretty=%B | pbcopy # Can also specify -2 for last two messages. 

Is it master or main?

git branch -l master main

# Do it all in one step
git fetch --all && git rebase -i origin/$(git branch -l master main)

Reuse previous commit message after git reset

git commit --reuse-message=HEAD@{1}
# shorter version
git commit -C HEAD@{1}
# even shorter!
git commit -C@@{1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment