For my github archive I received a pull request, which I wanted to test first before merging, and therefore used the commandline commands recommended by github (contrib1 represent the user name of the contributor, patch1 the name of the pull request, and repo the name of the repository)
git checkout -b contrib1-patch1 master
git pull https://github.com/contrib1/repo.git patch1
Because I had made some changes beforehand, a (trivial) merge conflict resolved, which I solved by editing file1. The patch also included non-conflicting changes to other files file2, ...
Then I followed the github suggestion again by:
git add file1
git checkout master
git merge --no-ff contrib1-patch1
git push origin master
The merge command resulted in a message "already up-to-date" I then figured out that I had omitted to commit first, so repeated essentially the procedure:
git commit -m "Implements patch1 by contrib1" repo
git checkout master
git merge --no-ff contrib1-patch1
git push origin master
Again, git merge --no-ff
resulted in the message "already up-to-date". The repository is now correct, but shows myself in a blame as the originator of the changes in all the files, not just the conflicted lines, which I feel is bad from the point-of-view of assigning credit to the external contributor.
The question is what sequence of commands should I use next time to avoid this scenario and make sure the patch author is shown in the blame or history view? Note that I am not concerned about changing history for the patch above, I only want to do it right for the next patch. Most likely the same problem would have appeared if I had not made the mistake of forgetting the commit
(clearly a 'local' issue) but in case it is important I felt I should report it.
Use git rebase -i
then set the original author of the commit via
git commit --amend --author "Original Author Name <[email protected]>"
More details on how to change authors here. From memory there are some additional hoops to jump through to change authorship of the merge commit, but that seems OK given you did the merge.