Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 1.32 KB

add-co-author-to-commit.md

File metadata and controls

64 lines (48 loc) · 1.32 KB

Add a co-author to commit

Get email of the author.

Find some old commit, clone the repo, switch to the branch and execute git log to get name and email.

Amend the last commit:

git commit --amend

Then just add the following line:

Co-Authored-By: Name <[email protected]>

Amend some older commit

First list all the commits:

git log

and find the commit that needs modification, e.g. abcdef

git rebase --interactive 'abcdef^'

Please note the caret ^ at the end of the command, because you need actually to rebase back to the commit before the one you wish to modify.

In the default editor, modify pick to edit in the line mentioning 'abcdef'.

Save the file and exit: git will interpret and automatically execute the commands in the file. You will find yourself in the previous situation in which you just had created commit abcdef.

At this point, abcdef is your last commit and you can easily amend it. Make your changes and then commit them with the command:

git commit --amend

Then just add the following line:

Co-Authored-By: Name <[email protected]>

After this, continue:

git rebase --continue

to return back to the previous HEAD commit.

When done, review the changes:

git log

then push:

git push --force