1

GitHub made changes recently to stop using some generic domains that meant that the dummy email address I was using for commits (to keep my actual email address private) was no longer correct to have contributions counted.

The help at GitHub told me to use the this https://help.github.com/articles/changing-author-info on lmy local clone to change the author info for previous commits, which I duly did in the Git Bash... which went through the rewrite, and informed me that `Ref 'refs/heads/master' was rewritten.

What now? Do I commit/push? There are no changes showing in the repository and the Github repo hasnt changed....

Toby
  • 9,696
  • 16
  • 68
  • 132
  • 1
    If you run `git log` do the commits contain the new email? – Peter Foti Feb 18 '14 at 11:18
  • is this your project only, or is it a public project? – Mohammad AbuShady Feb 18 '14 at 11:19
  • @PeterFoti Yes the emails are changed. – Toby Feb 18 '14 at 11:23
  • @MohammadAbuShady It's public https://github.com/wolf99/SCPI_Build – Toby Feb 18 '14 at 11:24
  • 1
    You should understand that by this change your branch is no longer a fast-forward commit, and to push it you need to overwrite the whole remote branch ( or at least since the oldest commit that contained your old email ), if you run some visual tool like `gitk` you'll see. how many changed commits does `git status` report ? – Mohammad AbuShady Feb 18 '14 at 11:25
  • OK, my branch has 241 and the origin/master has 240. Should I `pull` to fix or would that overwrite the author changes? – Toby Feb 18 '14 at 11:30
  • So I ran the script, did a `git pull` then `git push` and that seems to have worked as intended. As noted at http://stackoverflow.com/a/16900329/1292918 there is a backup copy of the history in refs/original kept that can be got rid of after the exercise is complete. – Toby Feb 18 '14 at 12:28
  • @MohammadAbuShady If you would like to make your comment an answer I will accept it. Thanks. – Toby Feb 18 '14 at 12:29
  • this somehow isn't logical to me, how many commits do you have now after pulling ? – Mohammad AbuShady Feb 18 '14 at 12:38
  • I just checked and as I expected, your commits number was doubled, your old commits still exist, are you fine with keeping them ? – Mohammad AbuShady Feb 18 '14 at 12:40
  • @MohammadAbuShady What should I do to get rid of the old commits? – Toby Feb 20 '14 at 16:03
  • 1
    well if you don't care about your history, I think you should force push and overwrite the tree – Mohammad AbuShady Feb 20 '14 at 17:46

2 Answers2

0

Force push was the answer so, as indicated by @MohammadAbuShady

Toby
  • 9,696
  • 16
  • 68
  • 132
0

Create a new branch and execute this command line (take care with this command, read more here: https://git-scm.com/docs/git-filter-branch):

git filter-branch -f --env-filter "GIT_AUTHOR_NAME='your name'; GIT_AUTHOR_EMAIL='your_email@mail.com'; GIT_COMMITTER_NAME='your name'; GIT_COMMITTER_EMAIL='your_email@mail.com';" HEAD

After that, publish the new branch and if you need, change the new branch as the main branch (if you are lonely in the project).