Question

I have recently cloned an hg repo to git so i can post it on github. Lots of the email addresses are wrong and I would like to use git rebase to change them before anyone forks this project. If i change them how do I go about pushing the new, completely rebased repo to github? can I just rebase and then git push? do i have to delete the project first?

Was it helpful?

Solution

Almost. You need to use git push -f (or --force) in order to overwrite the old history.


On a completely different note: why would you "like to use git rebase" to change the committer e-mail addresses instead of git filter-branch --env-filter?

OTHER TIPS

I don't have enough reputation just yet to comment on Jörg's post, but github has a nice shell script using git filter-branch --env-filter that helped me do the same thing at http://help.github.com/changing-author-info/. This is an example of what the other commenters on Jörg's post were talking about. This worked for me.

One way to do it is the following:

  • Create a .mbox file which contains all the patches since the repo's inception: git format-patch --stdout --root > repo_history.mbox
  • Edit the repo_history.mbox file, changing all e-mail addresses as you see fit. It could be as easy as perl -pi~ -e's/oldemail\@host\.org/newemail\@newhost\.com/gi' repo_history.mbox
  • Create a new repo: mkdir ~/newrepo; cd ~/newrepo; git init
  • Apply the previous mbox's changes to the new repo: git am /path/to/repo_history.mbox

I just tested it on a repo of mine, and it seems like the above has done the trick. Let me know if you'd like more details.

Important: You should only do this before you ever publish that repository, and not once other people have already pulled from it -- I see your question states that already, but this is just to reiterate the importance of this :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top