{"thread":{"id":"29391","subject":"modifying the commits before push","startedAt":"2012-01-18T17:49:27Z","lastAt":"2012-01-18T22:01:39Z","messageCount":4,"participants":["Sam Steingold","Dirk Süsserott","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"182729","messageId":"87wr8o3nq0.fsf@gnu.org","threadId":"29391","inReplyTo":null,"subject":"modifying the commits before push","fromName":"Sam Steingold","fromEmail":"sds@gnu.org","sentAt":"2012-01-18T17:49:27Z","receivedAt":"2012-01-18T17:49:27Z","isPatch":false,"sender":{"key":"sds@gnu.org","avatar":null},"body":"Hi,\nI am trying to push:\n$ git status\n# On branch master\n# Your branch is ahead of 'origin/master' by 4 commits.\n#\nnothing to commit (working directory clean)\n$\nbut `git push` fails with this:\n\nremote: ERROR: Rejecting update because this commit email is not from ZZZ\n\nWhat I need to do is\n- modify the 4 commits with a different e-mail and do `git push` again\n- make sure that all my commits in this repo are done with the correct e-mail\n\nhow do I do this?\n\nthanks!\n\n-- \nSam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000\nhttp://pmw.org.il http://jihadwatch.org http://thereligionofpeace.com\nhttp://openvotingconsortium.org http://ffii.org http://camera.org\nLet us remember that ours is a nation of lawyers and order.\n"},{"id":"182737","messageId":"4F17291A.8020600@dirk.my1.cc","threadId":"29391","inReplyTo":"87wr8o3nq0.fsf@gnu.org","subject":"Re: modifying the commits before push","fromName":"Dirk Süsserott","fromEmail":"newsletter@dirk.my1.cc","sentAt":"2012-01-18T20:18:34Z","receivedAt":"2012-01-18T20:18:34Z","isPatch":false,"sender":{"key":"newsletter@dirk.my1.cc","avatar":null},"body":"Am 18.01.2012 18:49 schrieb Sam Steingold:\n> Hi,\n> I am trying to push:\n> $ git status\n> # On branch master\n> # Your branch is ahead of 'origin/master' by 4 commits.\n> #\n> nothing to commit (working directory clean)\n> $\n> but `git push` fails with this:\n> \n> remote: ERROR: Rejecting update because this commit email is not from ZZZ\n> \n> What I need to do is\n> - modify the 4 commits with a different e-mail and do `git push` again\n> - make sure that all my commits in this repo are done with the correct e-mail\n> \n> how do I do this?\n> \n> thanks!\n> \n\n\nHi Sam,\n\nto modify the last 4 commits you can use git filter-branch (see the\nmanpage):\n\n$ git checkout master\n$ git filter-branch --env-filter \\\n   'GIT_COMMITTER_EMAIL=\"sds@gnu.org\" \\\n    GIT_COMMITTER_NAME=\"Sam Steingold\"' \\\n   HEAD~4..HEAD\n\nIt should tell you that it rewrites 4 commits. The original tree is\nsaved under original/refs/heads/master. If sth. went wrong, reset your\nmaster to that point (easiest with gitk, it's steel blue). If it worked,\nyou can delete the original/refs/heads/master like so:\n\n$ git for-each-ref --format=\"%(refname)\" \\\n    refs/original/ | xargs -n 1 git update-ref -d\n\nNote: Whether it worked or not, remove the original refs afterwards,\nbecause a second run of git filter-branch will fail if there's already\nan \"original\" tree.\n\nTo change your address for future commits configure it in .gitconfig in\nyour $HOME (--global) or on a per repo basis in .git/config (--local):\n\n$ git config --global user.email \"sds@gnu.org\"\n$ git config --global user.name \"Sam Steingold\"\n\nOr use git gui for this step (Edit -> Options).\n\nHTH\n    Dirk\n"},{"id":"182741","messageId":"87sjjc3cpj.fsf@gnu.org","threadId":"29391","inReplyTo":"4F17291A.8020600@dirk.my1.cc","subject":"Re: modifying the commits before push","fromName":"Sam Steingold","fromEmail":"sds@gnu.org","sentAt":"2012-01-18T21:47:20Z","receivedAt":"2012-01-18T21:47:20Z","isPatch":false,"sender":{"key":"sds@gnu.org","avatar":null},"body":"Hi Dirk,\n\n> * Dirk Süsserott <arjfyrggre@qvex.zl1.pp> [2012-01-18 21:18:34 +0100]:\n> Am 18.01.2012 18:49 schrieb Sam Steingold:\n>\n> to modify the last 4 commits you can use git filter-branch (see the\n> manpage):\n>\n> $ git checkout master\n> $ git filter-branch --env-filter \\\n>    'GIT_COMMITTER_EMAIL=\"sds@gnu.org\" \\\n>     GIT_COMMITTER_NAME=\"Sam Steingold\"' \\\n>    HEAD~4..HEAD\n>\n> It should tell you that it rewrites 4 commits.\n\nI did this; I got a few messages which scrolled very quickly.\nstatus code was 0, apparently, I was successful.\n\n> The original tree is saved under original/refs/heads/master.\n\nwhere is that?\n\n> If sth. went wrong, reset your master to that point (easiest with\n> gitk, it's steel blue). If it worked, you can delete the\n> original/refs/heads/master like so:\n>\n> $ git for-each-ref --format=\"%(refname)\" \\\n>     refs/original/ | xargs -n 1 git update-ref -d\n>\n> Note: Whether it worked or not, remove the original refs afterwards,\n> because a second run of git filter-branch will fail if there's already\n> an \"original\" tree.\n\nalas, I could not push because the remote tree was modified in the\nmeantime, I pulled and now:\n\n# On branch master\n# Your branch is ahead of 'origin/master' by 23 commits.\n#\nnothing to commit (working directory clean)\n\n\nso, what do I do now?\n\nis there a way for me to get back my original 4 patches, reset my tree\n(maybe by rm-rf+clone) and then re-apply them?\n\nthanks!\n\n-- \nSam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000\nhttp://jihadwatch.org http://memri.org http://thereligionofpeace.com\nhttp://www.PetitionOnline.com/tap12009/ http://palestinefacts.org\nI don't have an attitude problem. You have a perception problem.\n"},{"id":"182742","messageId":"m262g8r7p8.fsf@igel.home","threadId":"29391","inReplyTo":"87sjjc3cpj.fsf@gnu.org","subject":"Re: modifying the commits before push","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-01-18T22:01:39Z","receivedAt":"2012-01-18T22:01:39Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Sam Steingold <sds@gnu.org> writes:\n\n> alas, I could not push because the remote tree was modified in the\n> meantime, I pulled and now:\n>\n> # On branch master\n> # Your branch is ahead of 'origin/master' by 23 commits.\n\nWhat exactly did you do to get the additional 19 commits?\n\n> is there a way for me to get back my original 4 patches, reset my tree\n> (maybe by rm-rf+clone) and then re-apply them?\n\nYou can find them in the reflog (git log -g).\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"}]}