Skip to content

Instantly share code, notes, and snippets.

@cmackenzie1
Created February 6, 2024 19:28
Show Gist options
  • Save cmackenzie1/7743a88eb95fef330d45a0f37b145f17 to your computer and use it in GitHub Desktop.
Save cmackenzie1/7743a88eb95fef330d45a0f37b145f17 to your computer and use it in GitHub Desktop.

Revisions

  1. cmackenzie1 created this gist Feb 6, 2024.
    24 changes: 24 additions & 0 deletions git.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    ## Copy last commit message to clipboard

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

    ## Is it `master` or `main`?

    ```bash
    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`

    ```bash
    git commit --reuse-message=HEAD@{1}
    # shorter version
    git commit -C HEAD@{1}
    # even shorter!
    git commit -C@@{1}
    ```