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?
views:
46answers:
2
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 asperl -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
2010-08-31 18:30:37
+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
2010-08-31 19:27:12
i was using the term rebase to include anything that rewrites the commits.
Arthur Ulfeldt
2010-09-01 00:20:35
after doing this github lists both an Author and a Committer for each commit?
Arthur Ulfeldt
2010-09-01 04:58:20
@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
2010-09-01 05:51:27
Thanks Chris, now it's cleanly up on github AND google code :)
Arthur Ulfeldt
2010-09-01 18:13:04