6

I recently replaced the author, committer and emails thereof in all of my local commits, using the following command:

git filter-branch -f --env-filter '
if [ "$GIT_COMMITTER_NAME" = "oldname" ];
then
    GIT_COMMITTER_NAME="newname";
    GIT_COMMITTER_EMAIL="newaddr";
    GIT_AUTHOR_NAME="newname";
    GIT_AUTHOR_EMAIL="newaddr";
fi

if [ "$GIT_AUTHOR_NAME" = "oldname" ];
then
    GIT_COMMITTER_NAME="newname";
    GIT_COMMITTER_EMAIL="newaddr";
    GIT_AUTHOR_NAME="newname";
    GIT_AUTHOR_EMAIL="newaddr";
fi
' -- --all

The updates are immediately evident locally (e.g. in my SourceTree environment). However, after force-pushing the modified repository to GitHub…

git push -f origin master

… two individual items stubbornly refuse to have their committer and author updated: the Gemfile.lock file and a Views directory.

Please also note that:

  1. This is the second time that I am performing this kind of operation on this repository. I believe that I faced no such issues the first time around.

  2. Searching for my old name in the repository…

    $ find . "<oldname">
    

does yield a bunch of results, which means that the oldname still lurks in many of the repository files — including files that appear update both on GitHub and locally.

My question, then: How can I change the committer/author of the two "stubborn" files on GitHub?

BorromeanNot
  • 291
  • 3
  • 7
  • 1
    Perhaps GitHub is caching this information? Does pushing the repo to a new branch or a new repo cause the same problem? – Vladimir Panteleev Sep 08 '12 at 17:53
  • 1
    What do you mean when you say Gemfile.lock and Views "refuse to have their committer and author updated"? Only commits have committer and author, not trees and blobs. Also, the filter-branch you ran wouldn't do anything about files with the name "oldname". Also, it might help to post the github URL. – Max Nanasy Oct 09 '12 at 21:10
  • Related: [How do I change the author of a commit in git?](http://stackoverflow.com/q/750172/456814). –  May 18 '14 at 16:38

2 Answers2

6

After using git filter-branch, git still retains a backup copy of the history of the repo in refs/original. This is so that if you mess something up with filter-branch, you can revert if need be. Once you're sure everything went smoothly, you can remove the backed up ref with:

git update-ref -d refs/original/refs/heads/master

For some reason, it still takes an additional commit for github to reflect the change. I'll add a space or something to the readme, commit and push... after that, github reflects the correct authors on the project page.

Alex Medearis
  • 176
  • 1
  • 7
0

What exact view on GitHub are you using to determine the author of the line? Likely it is either cached, or you are viewing something specific to the old commit SHA1.

You can test that it worked by doing a fresh clone of the repo, and checking git blame filename for those two files. If that shows the correct author, then it worked.

asmeurer
  • 86,894
  • 26
  • 169
  • 240