Git


Merge multiple commits

Merge multiple previous commits together in a single commit.

git rebase -i HEAD~[NUMBER OF COMMITS TO MERGE]

Then, replace pick by squash on lines you want to discard the log message. Finally, remove the commit messages you want to discard to avoid being left with a multiline commit.

Rewrite author history

Change the author name and email address of all your commits in the history.

git filter-branch --commit-filter '
        if [ "$GIT_AUTHOR_EMAIL" = "original@email.address" ];
        then
                GIT_AUTHOR_NAME="New Name";
                GIT_AUTHOR_EMAIL="new@email.address";
                git commit-tree "$@";
        else
                git commit-tree "$@";
        fi' HEAD
git push --force --tags origin HEAD:master

This will rewrite your git history!