Authors
Show author names and their contributions to a repo
Show
In a Git repo, show a summary of GitHub users (using author names) and the number of commits by each, sorted by commit count.
$ git shortlog -n -s
969 michaelcurrin
123 MichaelCurrin
116 Alessio Benvenuti
For more info, see the shortlog command.
Edit
Change the author of a commit.
Edit one commit
If you just want to change the most recent commit, just amend the commit. No need to rebase.
$ git commit --amend --no-edit --reset-author
Setting --reset-author
is useful if you are changing someone else’s commit and want to appear as commiter. And also if you changed your Git config to another name and email address and you want to this to reflect.
Set a specific author:
$ git commit --amend --no-edit --author="John Doe <john@doe.org>"
Edit range of commits by hand
How to update one commit at a time, using Git manually one command at a time.
Note that this convenient for fixing a handful of commits, but is inefficient for changing a lot of commits.
- Set your new author name and email in a variable. e.g.
$ export AUTHOR="John Doe <john@doe.org>"
- Start a rebase, starting with one commit before the first commit you want to update.
$ git rebase -i -p COMMIT_REFERENCE
e.g. use the carat and the target first commit to get one commit before it.
$ git rebase -i -p fd27b00ac^
- Change
pick
toedit
ore
for each commit where you want to change the author. Warning - this will replace the author regardless of who it was. - Save the content in the editor view then exit.
- Now you adjust each commit one at a time with these two commands:
$ git commit --amend --no-edit --author="$AUTHOR" $ git rebase --continue
Bulk editing
Replace the author across the history of commits, using a single command.
See my MichaelCurrin/rewrite-git-author repo.