tags:

views:

46

answers:

2

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?

A: 

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 :)

mfontani
+1  A: 

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?

Jörg W Mittag
i was using the term rebase to include anything that rewrites the commits.
Arthur Ulfeldt
after doing this github lists both an Author and a Committer for each commit?
Arthur Ulfeldt
@Arthur: github shows both identities when they are different. When using `git filter-branch --env-filter`, be sure to update GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL, as well as GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL.
Chris Johnsen
Thanks Chris, now it's cleanly up on github AND google code :)
Arthur Ulfeldt