{"thread":{"id":"12795","subject":"Re: How to rewrite author history","startedAt":"2008-03-21T16:41:14Z","lastAt":"2008-03-23T07:09:45Z","messageCount":7,"participants":["Andrew Arnott","Dmitry Potapov","Samuel Tardieu","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"72602","messageId":"216e54900803210941i7fe345c2va850fa3ded8eabc8@mail.gmail.com","threadId":"12795","inReplyTo":"216e54900803210938q4981b5d1t535af419f5b15ad8@mail.gmail.com","subject":"Re: How to rewrite author history","fromName":"Andrew Arnott","fromEmail":"andrewarnott@gmail.com","sentAt":"2008-03-21T16:41:14Z","receivedAt":"2008-03-21T16:41:14Z","isPatch":false,"sender":{"key":"andrewarnott@gmail.com","avatar":"https://gravatar.com/avatar/e5c2778a1fae32d11e605bca8a9f56f78c43f0b042a5a907471bc4f01cfea4a5?d=mp&s=160"},"body":"I imported my git repo from an SVN repo, and the authors have\nemail@SOME-GUID for their email address rather than their actual one\n(probably courtesy of Google Code hosting).  Rewriting history and\nchanging all the commit hashes isn't a problem at this point in\ndevelopment, so how can I do a massive search-and-replace to replace\nseveral specific author emails with the valid ones?\n-- \nAndrew Arnott\n"},{"id":"72610","messageId":"37fcd2780803211140h7308d868t1555e0fc1f2716fc@mail.gmail.com","threadId":"12795","inReplyTo":"216e54900803210941i7fe345c2va850fa3ded8eabc8@mail.gmail.com","subject":"Re: How to rewrite author history","fromName":"Dmitry Potapov","fromEmail":"dpotapov@gmail.com","sentAt":"2008-03-21T18:40:55Z","receivedAt":"2008-03-21T18:40:55Z","isPatch":false,"sender":{"key":"dpotapov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6568595?v=4"},"body":"On Fri, Mar 21, 2008 at 7:41 PM, Andrew Arnott <andrewarnott@gmail.com> wrote:\n> I imported my git repo from an SVN repo, and the authors have\n>  email@SOME-GUID for their email address rather than their actual one\n>  (probably courtesy of Google Code hosting).  Rewriting history and\n>  changing all the commit hashes isn't a problem at this point in\n>  development, so how can I do a massive search-and-replace to replace\n>  several specific author emails with the valid ones?\n\nPlease, take a look at man git-filter-branch. I believe you can do\nthat using env-filter,\nbut I have never used this filter myself.\n\nDmitry\n"},{"id":"72647","messageId":"2008-03-22-10-29-23+trackit+sam@rfc1149.net","threadId":"12795","inReplyTo":"216e54900803210941i7fe345c2va850fa3ded8eabc8@mail.gmail.com","subject":"Re: How to rewrite author history","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2008-03-22T09:29:22Z","receivedAt":"2008-03-22T09:29:22Z","isPatch":false,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":">>>>> \"Andrew\" == Andrew Arnott <andrewarnott@gmail.com> writes:\n\nAndrew> I imported my git repo from an SVN repo, and the authors have\nAndrew> email@SOME-GUID for their email address rather than their\nAndrew> actual one (probably courtesy of Google Code hosting).\nAndrew> Rewriting history and changing all the commit hashes isn't a\nAndrew> problem at this point in development, so how can I do a\nAndrew> massive search-and-replace to replace several specific author\nAndrew> emails with the valid ones?\n\nIf you can reimport it, you can use the \"--authors-file\" of \"git svn\".\n\n  Sam\n"},{"id":"72656","messageId":"216e54900803220611v5aa5e9d5q86da249480be3c91@mail.gmail.com","threadId":"12795","inReplyTo":"2008-03-22-10-29-23+trackit+sam@rfc1149.net","subject":"Re: How to rewrite author history","fromName":"Andrew Arnott","fromEmail":"andrewarnott@gmail.com","sentAt":"2008-03-22T13:11:12Z","receivedAt":"2008-03-22T13:11:12Z","isPatch":false,"sender":{"key":"andrewarnott@gmail.com","avatar":"https://gravatar.com/avatar/e5c2778a1fae32d11e605bca8a9f56f78c43f0b042a5a907471bc4f01cfea4a5?d=mp&s=160"},"body":"Thanks.  Re-importing from SVN isn't an option any more, but I ended\nup with something like this that seems to have worked.\n\ngit checkout master\ngit-filter-branch --env-filter '\nif [ \"$GIT_AUTHOR_NAME\" = \"andrewarnott\" ];\nthen\nexport GIT_AUTHOR_EMAIL=\"andrewarnott@gmail.com\"\nexport GIT_AUTHOR_NAME=\"Andrew Arnott\"\nfi\nexport GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL\nexport GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME\n'\n\nAnd I did this for master, and my v1 and v0.1 branches.  I'm concerned\nthough, that since I changed the names of all the objects by doing\nthis, did I somehow make my branches incompatible with each other?\nWill there be any problems in the future sharing commits or merging\nacross branches as a result?\n\nThanks.\n\nOn Sat, Mar 22, 2008 at 2:29 AM, Samuel Tardieu <sam@rfc1149.net> wrote:\n> >>>>> \"Andrew\" == Andrew Arnott <andrewarnott@gmail.com> writes:\n>\n>  Andrew> I imported my git repo from an SVN repo, and the authors have\n>  Andrew> email@SOME-GUID for their email address rather than their\n>  Andrew> actual one (probably courtesy of Google Code hosting).\n>  Andrew> Rewriting history and changing all the commit hashes isn't a\n>  Andrew> problem at this point in development, so how can I do a\n>  Andrew> massive search-and-replace to replace several specific author\n>  Andrew> emails with the valid ones?\n>\n>  If you can reimport it, you can use the \"--authors-file\" of \"git svn\".\n>\n>   Sam\n>\n>\n\n\n\n-- \nAndrew Arnott\n"},{"id":"72678","messageId":"20080322165737.GB7611@coredump.intra.peff.net","threadId":"12795","inReplyTo":"216e54900803220611v5aa5e9d5q86da249480be3c91@mail.gmail.com","subject":"Re: How to rewrite author history","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-03-22T16:57:37Z","receivedAt":"2008-03-22T16:57:37Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Mar 22, 2008 at 06:11:12AM -0700, Andrew Arnott wrote:\n\n> git-filter-branch --env-filter '\n> [...]\n> And I did this for master, and my v1 and v0.1 branches.  I'm concerned\n> though, that since I changed the names of all the objects by doing\n> this, did I somehow make my branches incompatible with each other?\n> Will there be any problems in the future sharing commits or merging\n> across branches as a result?\n\nThere are two concerns, and I'm not sure which you have (I think number\n1):\n\n  1. Your branches within the repository will not connect anymore. I\n     believe this is a non-issue with your filter, since the generated\n     commit IDs are deterministic. Certainly a toy case worked for me\n     with:\n\n       for i in master branch; do\n         git filter-branch --env-filter=... $i\n       done\n\n     You can also specify both to be done at the same time, which is\n     more efficient:\n\n       git filter-branch --env-filter=... master branch\n\n     You can check the graph structure with \"gitk master branch\" which\n     should show them connecting.\n\n  2. Your branches are now a different, rewritten history compared to\n     anyone who has cloned or fetched from you. This is unavoidable, and\n     the answer is either \"don't use filter-branch\" or \"tell everyone to\n     rebase their work on the new history.\" So the best time to\n     filter-branch is right after import, but before you start work.\n\n-Peff\n"},{"id":"72693","messageId":"216e54900803221206l39d61bcw1c546b9812968ac0@mail.gmail.com","threadId":"12795","inReplyTo":"20080322165737.GB7611@coredump.intra.peff.net","subject":"Re: How to rewrite author history","fromName":"Andrew Arnott","fromEmail":"andrewarnott@gmail.com","sentAt":"2008-03-22T19:06:37Z","receivedAt":"2008-03-22T19:06:37Z","isPatch":false,"sender":{"key":"andrewarnott@gmail.com","avatar":"https://gravatar.com/avatar/e5c2778a1fae32d11e605bca8a9f56f78c43f0b042a5a907471bc4f01cfea4a5?d=mp&s=160"},"body":"Thanks, Jeff.  That was very helpful.  I have published my repo online\nalready, but only a couple people (if even that) have cloned it by now\nand I am prepared to email the list of interested parties letting them\nknow.  About this rebasing thing, is there a better way than for them\nto just wipe their repo and clone again?  Would a simple git fetch and\ngit rebase do the trick?\n\nThanks again, everyone.\n\nOn Sat, Mar 22, 2008 at 9:57 AM, Jeff King <peff@peff.net> wrote:\n> On Sat, Mar 22, 2008 at 06:11:12AM -0700, Andrew Arnott wrote:\n>\n>  > git-filter-branch --env-filter '\n>  > [...]\n>\n> > And I did this for master, and my v1 and v0.1 branches.  I'm concerned\n>  > though, that since I changed the names of all the objects by doing\n>  > this, did I somehow make my branches incompatible with each other?\n>  > Will there be any problems in the future sharing commits or merging\n>  > across branches as a result?\n>\n>  There are two concerns, and I'm not sure which you have (I think number\n>  1):\n>\n>   1. Your branches within the repository will not connect anymore. I\n>      believe this is a non-issue with your filter, since the generated\n>      commit IDs are deterministic. Certainly a toy case worked for me\n>      with:\n>\n>        for i in master branch; do\n>          git filter-branch --env-filter=... $i\n>        done\n>\n>      You can also specify both to be done at the same time, which is\n>      more efficient:\n>\n>        git filter-branch --env-filter=... master branch\n>\n>      You can check the graph structure with \"gitk master branch\" which\n>      should show them connecting.\n>\n>   2. Your branches are now a different, rewritten history compared to\n>      anyone who has cloned or fetched from you. This is unavoidable, and\n>      the answer is either \"don't use filter-branch\" or \"tell everyone to\n>      rebase their work on the new history.\" So the best time to\n>      filter-branch is right after import, but before you start work.\n>\n>  -Peff\n>\n\n\n\n-- \nAndrew Arnott\n"},{"id":"72723","messageId":"20080323070944.GA17184@coredump.intra.peff.net","threadId":"12795","inReplyTo":"216e54900803221206l39d61bcw1c546b9812968ac0@mail.gmail.com","subject":"Re: How to rewrite author history","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-03-23T07:09:45Z","receivedAt":"2008-03-23T07:09:45Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Mar 22, 2008 at 12:06:37PM -0700, Andrew Arnott wrote:\n\n> Thanks, Jeff.  That was very helpful.  I have published my repo online\n> already, but only a couple people (if even that) have cloned it by now\n> and I am prepared to email the list of interested parties letting them\n> know.  About this rebasing thing, is there a better way than for them\n> to just wipe their repo and clone again?  Would a simple git fetch and\n> git rebase do the trick?\n\nShort answer: if they haven't done any work on top of yours, re-cloning\nis probably the simplest route.\n\nIf they do have work, then they will want to fetch and rebase. The\ncommands are fairly simple, but what is happening is a little tricky, so\nI'll subject you to some ascii art.\n\n  # user has commits C..D built on top of your original A..B (in the\n  # diagram, \"...\" refers to an arbitrary number of commits)\n  #\n  #  A--...--B <-- origin/master\n  #           \\\n  #            C--...--D <-- master\n  git fetch\n\n  # after the fetch, we now have the filtered A'..B' pointed to by\n  # origin/master, but the reflog for origin/master points to the\n  # original.\n  #\n  # A'--...--B' <-- origin/master\n  # A--...--B <-- origin/master@{1}\n  #          \\\n  #           C--...--D <-- master\n  #\n  # so now we can rebase. We want all of the commits between the\n  # _original_ upstream and our current state to be rebased on top\n  # of the new upstream.\n  git rebase --onto origin/master origin/master@{1} master\n\n\nThree things to note here.\n\n1. This works even if C..D is empty, so it is valid even if they didn't\ndo any work. Though in that case, simply doing \"git reset --hard\norigin/master\" would work just as well.\n\n2. The annoying thing is that you have to do this for every branch. So\ndepending on how many branches you have and how much work they did, it\nmay just be simpler to export the work as patches, re-clone, and then\napply:\n\n  git checkout master\n  git format-patch origin/master >/some/path/outside/repo\n  cd .. && rm -rf repo\n  git clone /path/to/repo && cd repo\n  git am /some/path/outside/repo\n\n3. Since you haven't changed the trees at all, a fetch will just need to\ndownload the new commits. Thus a fetch should be way less\nnetwork-intensive than a re-clone. Whether that matters, of course,\ndepends on your repo size and your users' bandwidth.\n\nHope that helps,\n-Peff\n"}]}