Skip to content

Instantly share code, notes, and snippets.

@joncardasis
Last active May 1, 2017 16: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 joncardasis/b8e24fab1df5e04d6a010226093d2d7f to your computer and use it in GitHub Desktop.
Save joncardasis/b8e24fab1df5e04d6a010226093d2d7f to your computer and use it in GitHub Desktop.
A list of git commands that I found very helpful and should remember.

Rewriting Commit History

This will rewrite the branch's commit history and is useful for combining users if two emails were used for a single user at any point.

Note: Since this edits all history, everyone will need to re-clone the repo in order to get the correct history on their local machines.

A list of users who committed can be viewed via git shortlog -s -n.

$ git filter-branch --commit-filter '
    if [ "$GIT_AUTHOR_EMAIL" = "jonViaDesktop@localhost" ];
    then
            GIT_AUTHOR_NAME="Jon Cardasis";
            GIT_AUTHOR_EMAIL="myGitHubEmail@example.com";
            git commit-tree "$@";
    else
            git commit-tree "$@";
    fi' HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment