{"thread":{"id":"20950","subject":"Commited to wrong branch","startedAt":"2009-09-15T10:31:07Z","lastAt":"2009-09-15T22:30:25Z","messageCount":20,"participants":["Howard Miller","Martin Langhoff","Björn Steinbrink","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"123219","messageId":"26ae428a0909150331q391ed39ak622902d175b46d84@mail.gmail.com","threadId":"20950","inReplyTo":null,"subject":"Commited to wrong branch","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2009-09-15T10:31:07Z","receivedAt":"2009-09-15T10:31:07Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"Hi,\n\nI am resurrecting a discussion from a week or two back (been on\nholiday).  As follows...\n\nI had made some changes to some files and then done a commit. Only\nthen did I realise that I had the wrong branch checked out. To make\nmatters worse I then did a 'git reset HEAD^' which means that I can\nnow no longer switch branches. I am stuck. I had some advice (thanks!)\nbut it was not complete. I'd appreciate some more help.\n\nI was advised to do a 'git reflog --branchname--' (I don't\nknow/understand what this command does) but it doesn't work. I just\nget 'usage: git reflog (expire | ...)'\n\nSo basically I am no further forward. Just to reiterate I need to...\n\n* remove the commit from my current branch (it tracks a remote so I\nwould prefer there to be no evidence to confuse other people after I\npush)\n* add the changes to the (other) branch they should have been added to.\n* not loose or break anything.\n\nAny (more) help appreciated.\n"},{"id":"123221","messageId":"46a038f90909150355h20b39c71w4af7e2be2920fdbb@mail.gmail.com","threadId":"20950","inReplyTo":"26ae428a0909150331q391ed39ak622902d175b46d84@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2009-09-15T10:55:58Z","receivedAt":"2009-09-15T10:55:58Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On Tue, Sep 15, 2009 at 12:31 PM, Howard Miller\n<howard@e-learndesign.co.uk> wrote:\n> I am resurrecting a discussion from a week or two back (been on\n> holiday).  As follows...\n>\n> I had made some changes to some files and then done a commit. Only\n> then did I realise that I had the wrong branch checked out. To make\n> matters worse I then did a 'git reset HEAD^' which means that I can\n> now no longer switch branches. I am stuck. I had some advice (thanks!)\n> but it was not complete. I'd appreciate some more help.\n\nHi Howard,\n\njust to make sure I understand your issue\n\n  1 - you were on branch X, thinking your were on branch Y\n  2 - edit, diff, commit, realised the mistake\n  3 - git reset HEAD^\n\nso if you now run `git status` and `git diff` it will show your\nchanges as if they were uncommitted and unstaged.\n\n(Before you start with various attempts to recover below, a great\ntrick is to make an instant-backup in case things go wrong: cd .. / ;\ncp -pr moodle.git moodle-backup.git ; cd moodle.git )\n\nYou can now try do do\n\n  4 - git checkout Y\n\nand if the changes are on files that don't change between X and Y,\nthen git will change the branches and keep your changes there. If the\nfiles are different between X and Y, it won't work.\n\nWhat I can recommend is to save your patch, as follows\n\n  5 - git diff > tempchanges.patch\n  6 - git reset --hard # this will discard your changes, careful\n  7 - git checkout Y\n  8 - patch -p1 < tempchanges.patch\n\nThe patch may not apply cleanly :-) -- note that patch is more\ntolerant of iffy merges than git's internal implementation (\"git\napply\") -- so it will succeed more often... but the results need\nreview.\n\nThere is a more git-style approach that is to use git-stash -- it uses\ngit-apply and may not do what you want. The steps are\n\n 5a - git stash # will save your changed files into a \"stashed commit\"\nand clear out the changes from your working copy\n 6a - git checkout Y\n 7a - git stash apply\n\nhth,\n\n\n\nm\n-- \n martin.langhoff@gmail.com\n martin@laptop.org -- School Server Architect\n - ask interesting questions\n - don't get distracted with shiny stuff  - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"},{"id":"123222","messageId":"26ae428a0909150405v3087016fxee5ac98057868677@mail.gmail.com","threadId":"20950","inReplyTo":"46a038f90909150355h20b39c71w4af7e2be2920fdbb@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2009-09-15T11:05:35Z","receivedAt":"2009-09-15T11:05:35Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"Hi Martin,\n\nI'm pretty shocked how difficult this is... still...\n\nI'm finding git logs and reflogs pretty difficult to read and\ninterpret (head melting) - in particular telling what happened on what\nbranch - but looking at the reflog (which I assume is showing me the\nactions on the current branch, but I'm not sure) I think I must have\nmade two commits on the wrong branch so the reset has only 'popped'\nthe top one. Other than that your interpretation is correct.\n\nI cannot currently change branches - it only complains about one file.\nI'm a bit worried about that - I would like to understand why this is\na problem but I don't.\n\nSo I am now a little hazy on how to deal with previous TWO commits.\n\nSorry for misery.... I've lost the plot a bit here :-)\n\nHoward\n\n\n\n2009/9/15 Martin Langhoff <martin.langhoff@gmail.com>:\n> On Tue, Sep 15, 2009 at 12:31 PM, Howard Miller\n> <howard@e-learndesign.co.uk> wrote:\n>> I am resurrecting a discussion from a week or two back (been on\n>> holiday).  As follows...\n>>\n>> I had made some changes to some files and then done a commit. Only\n>> then did I realise that I had the wrong branch checked out. To make\n>> matters worse I then did a 'git reset HEAD^' which means that I can\n>> now no longer switch branches. I am stuck. I had some advice (thanks!)\n>> but it was not complete. I'd appreciate some more help.\n>\n> Hi Howard,\n>\n> just to make sure I understand your issue\n>\n>  1 - you were on branch X, thinking your were on branch Y\n>  2 - edit, diff, commit, realised the mistake\n>  3 - git reset HEAD^\n>\n> so if you now run `git status` and `git diff` it will show your\n> changes as if they were uncommitted and unstaged.\n>\n> (Before you start with various attempts to recover below, a great\n> trick is to make an instant-backup in case things go wrong: cd .. / ;\n> cp -pr moodle.git moodle-backup.git ; cd moodle.git )\n>\n> You can now try do do\n>\n>  4 - git checkout Y\n>\n> and if the changes are on files that don't change between X and Y,\n> then git will change the branches and keep your changes there. If the\n> files are different between X and Y, it won't work.\n>\n> What I can recommend is to save your patch, as follows\n>\n>  5 - git diff > tempchanges.patch\n>  6 - git reset --hard # this will discard your changes, careful\n>  7 - git checkout Y\n>  8 - patch -p1 < tempchanges.patch\n>\n> The patch may not apply cleanly :-) -- note that patch is more\n> tolerant of iffy merges than git's internal implementation (\"git\n> apply\") -- so it will succeed more often... but the results need\n> review.\n>\n> There is a more git-style approach that is to use git-stash -- it uses\n> git-apply and may not do what you want. The steps are\n>\n>  5a - git stash # will save your changed files into a \"stashed commit\"\n> and clear out the changes from your working copy\n>  6a - git checkout Y\n>  7a - git stash apply\n>\n> hth,\n>\n>\n>\n> m\n> --\n>  martin.langhoff@gmail.com\n>  martin@laptop.org -- School Server Architect\n>  - ask interesting questions\n>  - don't get distracted with shiny stuff  - working code first\n>  - http://wiki.laptop.org/go/User:Martinlanghoff\n>\n"},{"id":"123223","messageId":"46a038f90909150416h60ea7d74xd2337fe50f603dcb@mail.gmail.com","threadId":"20950","inReplyTo":"26ae428a0909150405v3087016fxee5ac98057868677@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2009-09-15T11:16:44Z","receivedAt":"2009-09-15T11:16:44Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On Tue, Sep 15, 2009 at 1:05 PM, Howard Miller\n<howard@e-learndesign.co.uk> wrote:\n> I'm pretty shocked how difficult this is... still...\n\nNo prob. It's only hard at the beginning :-)\n\n> I'm finding git logs and reflogs pretty difficult to read and\n> interpret (head melting) - in particular telling what happened on what\n> branch -\n\nI found gitk enormously helpful to visualise things. Try\n\n gitk # will show you the current branch\n\n gitk X Y # will show you both branches\n\ngitk is a ton easier to visualise. git log is pretty good but won't\nshow merges, so it's limited.\n\ngit reflog is confusing, but it's mostly a tool to help when there's\nbeen a mess and you want to diagnose WTH happened...\n\n>but looking at the reflog (which I assume is showing me the\n> actions on the current branch, but I'm not sure)\n\nDon't worry about the reflog...\n\n>  I think I must have\n> made two commits on the wrong branch so the reset has only 'popped'\n> the top one. Other than that your interpretation is correct.\n\nOk, so looking at gitk, there would still be one \"wrong\" commit. Can\nyou confirm?\n\n> I cannot currently change branches - it only complains about one file.\n\nIf you did follow my previous instructions (specially doing 'git reset\n--hard'), then this should not happen. Except...\n\nExcept when you have a file that git is not tracking, and it exists in\nthe \"other\" branch. The commit you undid earlier probably added that\nfile. So just rm that file, and change branches.\n\n> I'm a bit worried about that - I would like to understand why this is\n> a problem but I don't.\n\nAbout the file? It was \"new\" in the commit you un-committed. So when\nyou do git reset --hard, git makes sure all the files it is\n_currently_ tracking are \"unchanged\". If that file was new, it ignores\nit. Just rm it and be happy.\n\n> So I am now a little hazy on how to deal with previous TWO commits.\n\nJust review gitk and confirm if there are more commits to unstich --\nand we'll  work from there\n\n\nm\n-- \n martin.langhoff@gmail.com\n martin@laptop.org -- School Server Architect\n - ask interesting questions\n - don't get distracted with shiny stuff  - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"},{"id":"123224","messageId":"20090915111922.GB31846@atjola.homenet","threadId":"20950","inReplyTo":"46a038f90909150355h20b39c71w4af7e2be2920fdbb@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-09-15T11:19:22Z","receivedAt":"2009-09-15T11:19:22Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.09.15 12:55:58 +0200, Martin Langhoff wrote:\n> On Tue, Sep 15, 2009 at 12:31 PM, Howard Miller\n> <howard@e-learndesign.co.uk> wrote:\n> > I am resurrecting a discussion from a week or two back (been on\n> > holiday).  As follows...\n> >\n> > I had made some changes to some files and then done a commit. Only\n> > then did I realise that I had the wrong branch checked out. To make\n> > matters worse I then did a 'git reset HEAD^' which means that I can\n> > now no longer switch branches. I am stuck. I had some advice (thanks!)\n> > but it was not complete. I'd appreciate some more help.\n> \n> Hi Howard,\n> \n> just to make sure I understand your issue\n> \n>   1 - you were on branch X, thinking your were on branch Y\n>   2 - edit, diff, commit, realised the mistake\n>   3 - git reset HEAD^\n> \n> so if you now run `git status` and `git diff` it will show your\n> changes as if they were uncommitted and unstaged.\n\nNot \"as if\", they are.\n\n> (Before you start with various attempts to recover below, a great\n> trick is to make an instant-backup in case things go wrong: cd .. / ;\n> cp -pr moodle.git moodle-backup.git ; cd moodle.git )\n> \n> You can now try do do\n> \n>   4 - git checkout Y\n> \n> and if the changes are on files that don't change between X and Y,\n> then git will change the branches and keep your changes there. If the\n> files are different between X and Y, it won't work.\n\nWell, then you could use \"git checkout -m Y\", to have git try a\nthree-way merge (which might of course leave conflicts).\n\n> What I can recommend is to save your patch, as follows\n> \n>   5 - git diff > tempchanges.patch\n>   6 - git reset --hard # this will discard your changes, careful\n>   7 - git checkout Y\n>   8 - patch -p1 < tempchanges.patch\n> \n> The patch may not apply cleanly :-) -- note that patch is more\n> tolerant of iffy merges than git's internal implementation (\"git\n> apply\") -- so it will succeed more often... but the results need\n> review.\n\nBut a lot worse than the usual 3-way merge stuff, like \"checkout -m\" or\n\"stash apply\". The advantage of \"stash\" + \"stash apply\" is that, in case\nof conflicts, you can easily retry to fix them over and over again,\nwhile with \"checkout -m\", you can't easily start over AFAIK.\n\n> There is a more git-style approach that is to use git-stash -- it uses\n> git-apply and may not do what you want.\n\nOnly \"stash apply --index\" uses \"git apply\", and only to re-apply the\nstaged changes. The changes for the working tree are applied using a\n3way merge.\n\nBjörn\n"},{"id":"123229","messageId":"26ae428a0909150510n56b1d4eg6565a6cca8c9b46c@mail.gmail.com","threadId":"20950","inReplyTo":"46a038f90909150416h60ea7d74xd2337fe50f603dcb@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2009-09-15T12:10:07Z","receivedAt":"2009-09-15T12:10:07Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"Martin,\n\nLooked at gitk - yes there is definitely one more commit still on the\ncurrent (wrong) branch.\n\nI deleted the offending file and have now successfully switched to the\nother (correct) branch.\n\nHoward\n\n2009/9/15 Martin Langhoff <martin.langhoff@gmail.com>:\n> On Tue, Sep 15, 2009 at 1:05 PM, Howard Miller\n> <howard@e-learndesign.co.uk> wrote:\n>> I'm pretty shocked how difficult this is... still...\n>\n> No prob. It's only hard at the beginning :-)\n>\n>> I'm finding git logs and reflogs pretty difficult to read and\n>> interpret (head melting) - in particular telling what happened on what\n>> branch -\n>\n> I found gitk enormously helpful to visualise things. Try\n>\n>  gitk # will show you the current branch\n>\n>  gitk X Y # will show you both branches\n>\n> gitk is a ton easier to visualise. git log is pretty good but won't\n> show merges, so it's limited.\n>\n> git reflog is confusing, but it's mostly a tool to help when there's\n> been a mess and you want to diagnose WTH happened...\n>\n>>but looking at the reflog (which I assume is showing me the\n>> actions on the current branch, but I'm not sure)\n>\n> Don't worry about the reflog...\n>\n>>  I think I must have\n>> made two commits on the wrong branch so the reset has only 'popped'\n>> the top one. Other than that your interpretation is correct.\n>\n> Ok, so looking at gitk, there would still be one \"wrong\" commit. Can\n> you confirm?\n>\n>> I cannot currently change branches - it only complains about one file.\n>\n> If you did follow my previous instructions (specially doing 'git reset\n> --hard'), then this should not happen. Except...\n>\n> Except when you have a file that git is not tracking, and it exists in\n> the \"other\" branch. The commit you undid earlier probably added that\n> file. So just rm that file, and change branches.\n>\n>> I'm a bit worried about that - I would like to understand why this is\n>> a problem but I don't.\n>\n> About the file? It was \"new\" in the commit you un-committed. So when\n> you do git reset --hard, git makes sure all the files it is\n> _currently_ tracking are \"unchanged\". If that file was new, it ignores\n> it. Just rm it and be happy.\n>\n>> So I am now a little hazy on how to deal with previous TWO commits.\n>\n> Just review gitk and confirm if there are more commits to unstich --\n> and we'll  work from there\n>\n>\n> m\n> --\n>  martin.langhoff@gmail.com\n>  martin@laptop.org -- School Server Architect\n>  - ask interesting questions\n>  - don't get distracted with shiny stuff  - working code first\n>  - http://wiki.laptop.org/go/User:Martinlanghoff\n>\n"},{"id":"123231","messageId":"46a038f90909150546i508d3781id1dcd8e6c64942cf@mail.gmail.com","threadId":"20950","inReplyTo":"26ae428a0909150510n56b1d4eg6565a6cca8c9b46c@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2009-09-15T12:46:16Z","receivedAt":"2009-09-15T12:46:16Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On Tue, Sep 15, 2009 at 2:10 PM, Howard Miller\n<howard@e-learndesign.co.uk> wrote:\n> Martin,\n>\n> Looked at gitk - yes there is definitely one more commit still on the\n> current (wrong) branch.\n>\n> I deleted the offending file and have now successfully switched to the\n> other (correct) branch.\n\nok!\n\nso you have\n\nA - The commit you undid, and have in the temp patch. Note that this\npatch file is missing the file you've rm'd.\n\nB - A commit you haven't \"undone\" on the \"wrong\" branch X.\n\n and you are on branch Y\n\nso now...\n\n1 - git format-patch Y^..Y  # will export that patch B into a file for you.\n2 - git am 0001-whatever-the-name-of-the-file.txt # patch B\n    this may need conflict resolution - read the notes it prints! If\nit refuses to apply the patch, do \"git am --skip\" to indicate you\nwon't use git-am no more for this, and try applying it with the patch\nutility.\n3 - patch -p1 < your-patch-A.patch\n4 - find and readd the file you rm'd earlier -- if you don't have\nanother copy, we can get it from git reflog but that'll take extra\nsteps :-)\n5 - git commit # you're committing your patch A here\n\nNow, review with gitk to see that you have what you want to have\nthere. If it's all ok...\n\n 6 - git checkout X\n 7 - git reset --hard # unstich that last stray commit\n   --\n\nhope the above helps. Git pros will see that the process could be much\nshorter :-) I chose this specific path because in exporting your\npatches and applying them again you can see each step.\n\nIf we were to start again, and the branches are reasonably close to\neachother (not 19_STABLE vs cvshead :-) ) then you can say\n\n - X has 2 bad commits that belong to Y, then\n 1 - gitk X & # open gitk to visualise the commits, send it to the background\n 2 - git checkout Y\n 3 - git cherry-pick X^ # takes the next-to-last commit from X and\ntries to apply it here - conflict resolution may be needed\n 4 - git cherry-pick X # same with the very last commit on X\n 5 - gitk # check that is all as you want it\n 6 - git checkout X\n 7 - git reset --hard X^^ # \"rewind 2 commits\"\n\nhth,\n\n\n\nm\n-- \n martin.langhoff@gmail.com\n martin@laptop.org -- School Server Architect\n - ask interesting questions\n - don't get distracted with shiny stuff  - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"},{"id":"123233","messageId":"26ae428a0909150558i508e5878q8a1ee7cb7311fc57@mail.gmail.com","threadId":"20950","inReplyTo":"46a038f90909150546i508d3781id1dcd8e6c64942cf@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2009-09-15T12:58:32Z","receivedAt":"2009-09-15T12:58:32Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"Martin,\n\nGot as far as applying the temporary patch and I now get a load of...\n\nReversed (or previously applied) patch detected!  Assume -R? [n]\nApply anyway? [n]\nSkipping patch.\n1 out of 1 hunk ignored -- saving rejects to file\ntheme/onepointnine/local.css.rej\nThe next patch would create the file theme/onepointnine/local.css,\n\nfunnily I didn't think that file had anything to do with it, but when\nI changed branched I got\n\nT\ttheme/onepointnine/local.css\n\nNot sure what the T means :-(\n\nH.\n\n2009/9/15 Martin Langhoff <martin.langhoff@gmail.com>:\n> On Tue, Sep 15, 2009 at 2:10 PM, Howard Miller\n> <howard@e-learndesign.co.uk> wrote:\n>> Martin,\n>>\n>> Looked at gitk - yes there is definitely one more commit still on the\n>> current (wrong) branch.\n>>\n>> I deleted the offending file and have now successfully switched to the\n>> other (correct) branch.\n>\n> ok!\n>\n> so you have\n>\n> A - The commit you undid, and have in the temp patch. Note that this\n> patch file is missing the file you've rm'd.\n>\n> B - A commit you haven't \"undone\" on the \"wrong\" branch X.\n>\n>  and you are on branch Y\n>\n> so now...\n>\n> 1 - git format-patch Y^..Y  # will export that patch B into a file for you.\n> 2 - git am 0001-whatever-the-name-of-the-file.txt # patch B\n>    this may need conflict resolution - read the notes it prints! If\n> it refuses to apply the patch, do \"git am --skip\" to indicate you\n> won't use git-am no more for this, and try applying it with the patch\n> utility.\n> 3 - patch -p1 < your-patch-A.patch\n> 4 - find and readd the file you rm'd earlier -- if you don't have\n> another copy, we can get it from git reflog but that'll take extra\n> steps :-)\n> 5 - git commit # you're committing your patch A here\n>\n> Now, review with gitk to see that you have what you want to have\n> there. If it's all ok...\n>\n>  6 - git checkout X\n>  7 - git reset --hard # unstich that last stray commit\n>   --\n>\n> hope the above helps. Git pros will see that the process could be much\n> shorter :-) I chose this specific path because in exporting your\n> patches and applying them again you can see each step.\n>\n> If we were to start again, and the branches are reasonably close to\n> eachother (not 19_STABLE vs cvshead :-) ) then you can say\n>\n>  - X has 2 bad commits that belong to Y, then\n>  1 - gitk X & # open gitk to visualise the commits, send it to the background\n>  2 - git checkout Y\n>  3 - git cherry-pick X^ # takes the next-to-last commit from X and\n> tries to apply it here - conflict resolution may be needed\n>  4 - git cherry-pick X # same with the very last commit on X\n>  5 - gitk # check that is all as you want it\n>  6 - git checkout X\n>  7 - git reset --hard X^^ # \"rewind 2 commits\"\n>\n> hth,\n>\n>\n>\n> m\n> --\n>  martin.langhoff@gmail.com\n>  martin@laptop.org -- School Server Architect\n>  - ask interesting questions\n>  - don't get distracted with shiny stuff  - working code first\n>  - http://wiki.laptop.org/go/User:Martinlanghoff\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"},{"id":"123235","messageId":"20090915130640.GC31846@atjola.homenet","threadId":"20950","inReplyTo":"26ae428a0909150558i508e5878q8a1ee7cb7311fc57@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-09-15T13:06:40Z","receivedAt":"2009-09-15T13:06:40Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"[Please stop top-posting...]\n\nOn 2009.09.15 13:58:32 +0100, Howard Miller wrote:\n> Got as far as applying the temporary patch and I now get a load of...\n> \n> Reversed (or previously applied) patch detected!  Assume -R? [n]\n> Apply anyway? [n]\n> Skipping patch.\n> 1 out of 1 hunk ignored -- saving rejects to file\n> theme/onepointnine/local.css.rej\n> The next patch would create the file theme/onepointnine/local.css,\n\nJust don't use patch(1), there's no sane reason to do that, you're\nsacrificing all of what git can offer there.\n\ncherry-pick or format-patch + am -3 are simply much better. (Or\n\"checkout -m\" or stash + stash apply, if you're dealing with uncommitted\nchanges).\n\nBjörn\n"},{"id":"123236","messageId":"26ae428a0909150612i3a24c968h33757594f16995a8@mail.gmail.com","threadId":"20950","inReplyTo":"20090915130640.GC31846@atjola.homenet","subject":"Re: Commited to wrong branch","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2009-09-15T13:12:15Z","receivedAt":"2009-09-15T13:12:15Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"Please stop what?\n\nOk... thanks for all your help guys but I'm giving up. A silly mistake\nhas wasted a day. It shouldn't be like that. I appreciate that it's me\nthat doesn't know enough about the way git works but I don't want to\nknow. I don't have time - I have actual work to do. It'll be quicker\nto recreate the code I have lost.\n\nGit encourages one to be experimental and create branches and stuff\nall the time which is great but doesn't do enough to stop one getting\ncompletely confused. That's how it feels to me anyway. Yes I am in a\nsulk - sorry :-)\n\nHoward\n\n2009/9/15 Björn Steinbrink <B.Steinbrink@gmx.de>:\n> [Please stop top-posting...]\n>\n> On 2009.09.15 13:58:32 +0100, Howard Miller wrote:\n>> Got as far as applying the temporary patch and I now get a load of...\n>>\n>> Reversed (or previously applied) patch detected!  Assume -R? [n]\n>> Apply anyway? [n]\n>> Skipping patch.\n>> 1 out of 1 hunk ignored -- saving rejects to file\n>> theme/onepointnine/local.css.rej\n>> The next patch would create the file theme/onepointnine/local.css,\n>\n> Just don't use patch(1), there's no sane reason to do that, you're\n> sacrificing all of what git can offer there.\n>\n> cherry-pick or format-patch + am -3 are simply much better. (Or\n> \"checkout -m\" or stash + stash apply, if you're dealing with uncommitted\n> changes).\n>\n> Björn\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"},{"id":"123238","messageId":"26ae428a0909150627n4e5935bcxdcdf0fdd33a44aa8@mail.gmail.com","threadId":"20950","inReplyTo":"26ae428a0909150558i508e5878q8a1ee7cb7311fc57@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2009-09-15T13:27:21Z","receivedAt":"2009-09-15T13:27:21Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"What's to stop me.........\n\n* The \"wrong\" branch just tracks a remote so I can just dump it once I\nhave this fixed - (delete it and recreate it?)\n* after my 'reset' the files I have in my working copy (still the\nwrong branch) should be the latest version ('git reset' does not\nchange the working copy I think?)\n* So can I grab these files (they are mostly new), checkout the\ncorrect version, and just overwrite the existing files? I'll loose\nsome history but not much and I don't care\n\nSeems too easy :-)\n\n2009/9/15 Howard Miller <howard@e-learndesign.co.uk>:\n> Martin,\n>\n> Got as far as applying the temporary patch and I now get a load of...\n>\n> Reversed (or previously applied) patch detected!  Assume -R? [n]\n> Apply anyway? [n]\n> Skipping patch.\n> 1 out of 1 hunk ignored -- saving rejects to file\n> theme/onepointnine/local.css.rej\n> The next patch would create the file theme/onepointnine/local.css,\n>\n> funnily I didn't think that file had anything to do with it, but when\n> I changed branched I got\n>\n> T       theme/onepointnine/local.css\n>\n> Not sure what the T means :-(\n>\n> H.\n>\n> 2009/9/15 Martin Langhoff <martin.langhoff@gmail.com>:\n>> On Tue, Sep 15, 2009 at 2:10 PM, Howard Miller\n>> <howard@e-learndesign.co.uk> wrote:\n>>> Martin,\n>>>\n>>> Looked at gitk - yes there is definitely one more commit still on the\n>>> current (wrong) branch.\n>>>\n>>> I deleted the offending file and have now successfully switched to the\n>>> other (correct) branch.\n>>\n>> ok!\n>>\n>> so you have\n>>\n>> A - The commit you undid, and have in the temp patch. Note that this\n>> patch file is missing the file you've rm'd.\n>>\n>> B - A commit you haven't \"undone\" on the \"wrong\" branch X.\n>>\n>>  and you are on branch Y\n>>\n>> so now...\n>>\n>> 1 - git format-patch Y^..Y  # will export that patch B into a file for you.\n>> 2 - git am 0001-whatever-the-name-of-the-file.txt # patch B\n>>    this may need conflict resolution - read the notes it prints! If\n>> it refuses to apply the patch, do \"git am --skip\" to indicate you\n>> won't use git-am no more for this, and try applying it with the patch\n>> utility.\n>> 3 - patch -p1 < your-patch-A.patch\n>> 4 - find and readd the file you rm'd earlier -- if you don't have\n>> another copy, we can get it from git reflog but that'll take extra\n>> steps :-)\n>> 5 - git commit # you're committing your patch A here\n>>\n>> Now, review with gitk to see that you have what you want to have\n>> there. If it's all ok...\n>>\n>>  6 - git checkout X\n>>  7 - git reset --hard # unstich that last stray commit\n>>   --\n>>\n>> hope the above helps. Git pros will see that the process could be much\n>> shorter :-) I chose this specific path because in exporting your\n>> patches and applying them again you can see each step.\n>>\n>> If we were to start again, and the branches are reasonably close to\n>> eachother (not 19_STABLE vs cvshead :-) ) then you can say\n>>\n>>  - X has 2 bad commits that belong to Y, then\n>>  1 - gitk X & # open gitk to visualise the commits, send it to the background\n>>  2 - git checkout Y\n>>  3 - git cherry-pick X^ # takes the next-to-last commit from X and\n>> tries to apply it here - conflict resolution may be needed\n>>  4 - git cherry-pick X # same with the very last commit on X\n>>  5 - gitk # check that is all as you want it\n>>  6 - git checkout X\n>>  7 - git reset --hard X^^ # \"rewind 2 commits\"\n>>\n>> hth,\n>>\n>>\n>>\n>> m\n>> --\n>>  martin.langhoff@gmail.com\n>>  martin@laptop.org -- School Server Architect\n>>  - ask interesting questions\n>>  - don't get distracted with shiny stuff  - working code first\n>>  - http://wiki.laptop.org/go/User:Martinlanghoff\n>> --\n>> To unsubscribe from this list: send the line \"unsubscribe git\" in\n>> the body of a message to majordomo@vger.kernel.org\n>> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>>\n>\n"},{"id":"123255","messageId":"26ae428a0909150645s59e1fb40hbb19e672230077eb@mail.gmail.com","threadId":"20950","inReplyTo":"26ae428a0909150627n4e5935bcxdcdf0fdd33a44aa8@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2009-09-15T13:45:30Z","receivedAt":"2009-09-15T13:45:30Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"Martin et al.\n\nThanks for your help and sorry for ranting (also to Daniele Segato who\nreplied off-list).... these things always happen when you have the\nleast amount of time to deal with them!!\n\nProblem solved.... well bodged actually (just copied files which were\nall in one directory over to the correct branch).... but it will do. I\nshall be MUCH more careful in future :-)\n\nHoward\n\n(PS. I now even know what 'top-posting' is - but not why it's bad.)\n\n2009/9/15 Howard Miller <howard@e-learndesign.co.uk>:\n> What's to stop me.........\n>\n> * The \"wrong\" branch just tracks a remote so I can just dump it once I\n> have this fixed - (delete it and recreate it?)\n> * after my 'reset' the files I have in my working copy (still the\n> wrong branch) should be the latest version ('git reset' does not\n> change the working copy I think?)\n> * So can I grab these files (they are mostly new), checkout the\n> correct version, and just overwrite the existing files? I'll loose\n> some history but not much and I don't care\n>\n> Seems too easy :-)\n>\n> 2009/9/15 Howard Miller <howard@e-learndesign.co.uk>:\n>> Martin,\n>>\n>> Got as far as applying the temporary patch and I now get a load of...\n>>\n>> Reversed (or previously applied) patch detected!  Assume -R? [n]\n>> Apply anyway? [n]\n>> Skipping patch.\n>> 1 out of 1 hunk ignored -- saving rejects to file\n>> theme/onepointnine/local.css.rej\n>> The next patch would create the file theme/onepointnine/local.css,\n>>\n>> funnily I didn't think that file had anything to do with it, but when\n>> I changed branched I got\n>>\n>> T       theme/onepointnine/local.css\n>>\n>> Not sure what the T means :-(\n>>\n>> H.\n>>\n>> 2009/9/15 Martin Langhoff <martin.langhoff@gmail.com>:\n>>> On Tue, Sep 15, 2009 at 2:10 PM, Howard Miller\n>>> <howard@e-learndesign.co.uk> wrote:\n>>>> Martin,\n>>>>\n>>>> Looked at gitk - yes there is definitely one more commit still on the\n>>>> current (wrong) branch.\n>>>>\n>>>> I deleted the offending file and have now successfully switched to the\n>>>> other (correct) branch.\n>>>\n>>> ok!\n>>>\n>>> so you have\n>>>\n>>> A - The commit you undid, and have in the temp patch. Note that this\n>>> patch file is missing the file you've rm'd.\n>>>\n>>> B - A commit you haven't \"undone\" on the \"wrong\" branch X.\n>>>\n>>>  and you are on branch Y\n>>>\n>>> so now...\n>>>\n>>> 1 - git format-patch Y^..Y  # will export that patch B into a file for you.\n>>> 2 - git am 0001-whatever-the-name-of-the-file.txt # patch B\n>>>    this may need conflict resolution - read the notes it prints! If\n>>> it refuses to apply the patch, do \"git am --skip\" to indicate you\n>>> won't use git-am no more for this, and try applying it with the patch\n>>> utility.\n>>> 3 - patch -p1 < your-patch-A.patch\n>>> 4 - find and readd the file you rm'd earlier -- if you don't have\n>>> another copy, we can get it from git reflog but that'll take extra\n>>> steps :-)\n>>> 5 - git commit # you're committing your patch A here\n>>>\n>>> Now, review with gitk to see that you have what you want to have\n>>> there. If it's all ok...\n>>>\n>>>  6 - git checkout X\n>>>  7 - git reset --hard # unstich that last stray commit\n>>>   --\n>>>\n>>> hope the above helps. Git pros will see that the process could be much\n>>> shorter :-) I chose this specific path because in exporting your\n>>> patches and applying them again you can see each step.\n>>>\n>>> If we were to start again, and the branches are reasonably close to\n>>> eachother (not 19_STABLE vs cvshead :-) ) then you can say\n>>>\n>>>  - X has 2 bad commits that belong to Y, then\n>>>  1 - gitk X & # open gitk to visualise the commits, send it to the background\n>>>  2 - git checkout Y\n>>>  3 - git cherry-pick X^ # takes the next-to-last commit from X and\n>>> tries to apply it here - conflict resolution may be needed\n>>>  4 - git cherry-pick X # same with the very last commit on X\n>>>  5 - gitk # check that is all as you want it\n>>>  6 - git checkout X\n>>>  7 - git reset --hard X^^ # \"rewind 2 commits\"\n>>>\n>>> hth,\n>>>\n>>>\n>>>\n>>> m\n>>> --\n>>>  martin.langhoff@gmail.com\n>>>  martin@laptop.org -- School Server Architect\n>>>  - ask interesting questions\n>>>  - don't get distracted with shiny stuff  - working code first\n>>>  - http://wiki.laptop.org/go/User:Martinlanghoff\n>>> --\n>>> To unsubscribe from this list: send the line \"unsubscribe git\" in\n>>> the body of a message to majordomo@vger.kernel.org\n>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>>>\n>>\n>\n"},{"id":"123256","messageId":"46a038f90909150646t25c48d7ar1cfe4052ad0bb3b6@mail.gmail.com","threadId":"20950","inReplyTo":"26ae428a0909150627n4e5935bcxdcdf0fdd33a44aa8@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2009-09-15T13:46:43Z","receivedAt":"2009-09-15T13:46:43Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On Tue, Sep 15, 2009 at 3:27 PM, Howard Miller\n<howard@e-learndesign.co.uk> wrote:\n> What's to stop me.........\n>\n> * The \"wrong\" branch just tracks a remote so I can just dump it once I\n> have this fixed - (delete it and recreate it?)\n\nAbsolutely perfect plan. In fact, there's a way to \"sync\" your local\nbranch to the remote one:\n\n git checkout X\n git reset  origin/X\n\n(assuming that the remote branch is 'origin/X')\n\n> * after my 'reset' the files I have in my working copy (still the\n> wrong branch) should be the latest version ('git reset' does not\n> change the working copy I think?)\n\ncorrect (git reset --hard OTOH will discard your changes)\n\n> * So can I grab these files (they are mostly new), checkout the\n> correct version, and just overwrite the existing files? I'll loose\n> some history but not much and I don't care\n\nOh... well if there were other changes to the same files in the other\nbranch you could be carrying \"other\" changes. git diff to make sure\nyou're committing what you want.\n\n> Seems too easy :-)\n\nIt is :-)\n\n\nm\n\n-- \n martin.langhoff@gmail.com\n martin@laptop.org -- School Server Architect\n - ask interesting questions\n - don't get distracted with shiny stuff  - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"},{"id":"123257","messageId":"46a038f90909150654t73cab47ckfd02f8a2f4353722@mail.gmail.com","threadId":"20950","inReplyTo":"20090915130640.GC31846@atjola.homenet","subject":"Re: Commited to wrong branch","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2009-09-15T13:54:58Z","receivedAt":"2009-09-15T13:54:58Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"2009/9/15 Björn Steinbrink <B.Steinbrink@gmx.de>:\n> [Please stop top-posting...]\n\nNot everyone is deep in mailing-list lore :-) -- we can help anyway.\n\nHoward, I see you're wondering about it: http://www.idallen.com/topposting.html\n\n> Just don't use patch(1), there's no sane reason to do that, you're\n> sacrificing all of what git can offer there.\n\nOh, yes there is, specially for newcomers used to patch, and how it\nhandles conflicts.\n\nIn this case, I happen to know that Howard is a refugee from CVS land\n(the moodle project in this case), and he is familiar with the output\nof patch if things go wrong.\n\nIt's not what I'd recommend to someone that is deep in git-land. But\neven myself (with a bit of code in git) sometimes use patch when\ngit-apply tries to be too clever and I just want a damn .rej file to\nreview and edit with emacs.\n\ncheers,\n\n\nm\n-- \n martin.langhoff@gmail.com\n martin@laptop.org -- School Server Architect\n - ask interesting questions\n - don't get distracted with shiny stuff  - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"},{"id":"123259","messageId":"4AAF9FC7.2090003@viscovery.net","threadId":"20950","inReplyTo":"26ae428a0909150645s59e1fb40hbb19e672230077eb@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-09-15T14:08:07Z","receivedAt":"2009-09-15T14:08:07Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Howard Miller schrieb:\n> (PS. I now even know what 'top-posting' is - but not why it's bad.)\n\nA: Because it messes up the order in which people normally read text.\nQ: Why is top-posting such a bad thing?\nA: Top-posting.\nQ: What is the most annoying thing in e-mail?\n"},{"id":"123261","messageId":"26ae428a0909150711h1f7bc593j541d5eb7201a7e45@mail.gmail.com","threadId":"20950","inReplyTo":"46a038f90909150654t73cab47ckfd02f8a2f4353722@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2009-09-15T14:11:57Z","receivedAt":"2009-09-15T14:11:57Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"2009/9/15 Martin Langhoff <martin.langhoff@gmail.com>:\n> 2009/9/15 Björn Steinbrink <B.Steinbrink@gmx.de>:\n>> [Please stop top-posting...]\n>\n> Not everyone is deep in mailing-list lore :-) -- we can help anyway.\n>\n> Howard, I see you're wondering about it: http://www.idallen.com/topposting.html\n>\n>> Just don't use patch(1), there's no sane reason to do that, you're\n>> sacrificing all of what git can offer there.\n>\n> Oh, yes there is, specially for newcomers used to patch, and how it\n> handles conflicts.\n>\n> In this case, I happen to know that Howard is a refugee from CVS land\n> (the moodle project in this case), and he is familiar with the output\n> of patch if things go wrong.\n>\n> It's not what I'd recommend to someone that is deep in git-land. But\n> even myself (with a bit of code in git) sometimes use patch when\n> git-apply tries to be too clever and I just want a damn .rej file to\n> review and edit with emacs.\n>\n> cheers,\n>\n>\n> m\n> --\n>  martin.langhoff@gmail.com\n>  martin@laptop.org -- School Server Architect\n>  - ask interesting questions\n>  - don't get distracted with shiny stuff  - working code first\n>  - http://wiki.laptop.org/go/User:Martinlanghoff\n>\n\n...and I still don't understand cvs either  :-)\n\n(NB. I have put my reply at the bottom where nobody will see it - this\nis why forums are better than mailing lists.... >ducks<)\n"},{"id":"123283","messageId":"20090915203948.GA14652@atjola.homenet","threadId":"20950","inReplyTo":"46a038f90909150654t73cab47ckfd02f8a2f4353722@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-09-15T20:39:48Z","receivedAt":"2009-09-15T20:39:48Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.09.15 15:54:58 +0200, Martin Langhoff wrote:\n> 2009/9/15 Björn Steinbrink <B.Steinbrink@gmx.de>:\n> > Just don't use patch(1), there's no sane reason to do that, you're\n> > sacrificing all of what git can offer there.\n> \n> Oh, yes there is, specially for newcomers used to patch, and how it\n> handles conflicts.\n\nSooner or later you'll hit a merge conflict anyway, and conflict markers\naren't that hard to understand, and IMHO are easier to handle than .rej\nfiles, as you get to edit everything in-place.\n\n> In this case, I happen to know that Howard is a refugee from CVS land\n> (the moodle project in this case), and he is familiar with the output\n> of patch if things go wrong.\n\nUhm, CVS uses the same conflict markers that git uses.\n\n> It's not what I'd recommend to someone that is deep in git-land. But\n> even myself (with a bit of code in git) sometimes use patch when\n> git-apply tries to be too clever and I just want a damn .rej file to\n> review and edit with emacs.\n\nWell, you likely shouldn't be using git-apply, which is plumbing, and\ncan't easily make use of the \"index\" information in git patches to do a\nthree-way merge instead of a \"stupid\" patch application. Instead use\ngit-am --3way to make git perform a three-way merge, leading to\nconflicts instead of plain patch rejection.\n\nAnd in a case like Howard's, in which nothing is coming from outside the\nrepo, there's not even any reason to use am. It's already all in there,\nso \"checkout -m\", \"stash/stash apply\" (uncommitted changes) and\n\"cherry-pick\", \"rebase [-i]\" are way better than manually dealing with\nformat-patch + am or even apply.\n\nBjörn\n"},{"id":"123284","messageId":"26ae428a0909151352v1cc27b6dw1d77ac6dda0411ff@mail.gmail.com","threadId":"20950","inReplyTo":"20090915203948.GA14652@atjola.homenet","subject":"Re: Commited to wrong branch","fromName":"Howard Miller","fromEmail":"howard@e-learndesign.co.uk","sentAt":"2009-09-15T20:52:10Z","receivedAt":"2009-09-15T20:52:10Z","isPatch":false,"sender":{"key":"howard@e-learndesign.co.uk","avatar":"https://gravatar.com/avatar/ddb66c6a4a077e52b823ac5b04f33ab927cb90e2ab1eafedaeba07b1920bb99e?d=mp&s=160"},"body":"I don't imagine having a problem with conflict markers although I've\nnever had any in a git related project (yet!). I'm in the happy\nposition of working by myself at the moment which, in the end, is how\nI got out of my problem because I knew where all the changes where.\nInterestingly, the whole .rej file thing IS new to me. I've been using\npatch files for years and have never had that happen before. Hmmm...\n\nNever used emacs either - I'm a Vim-kid :-)\n\nMartin's point about simply copying the repo so you have a backup is\nat the same time dead simple and brilliant. It's almost an undo. I\nhave an idea that I could now fumble my way through a problem like\nthis. The bother is that git has too many commands and too little\n(idiot proof) help which is a shame. Not everybody is a power user -\nbut we are just the sort of people who mess up. I'm trying to put a\npositive spin on things - we need a git tips wiki or something.\nVersion control to me is a dull necessity - I don't want to have to\nthink about it!\n\nHoward\n\n2009/9/15 Björn Steinbrink <B.Steinbrink@gmx.de>:\n> On 2009.09.15 15:54:58 +0200, Martin Langhoff wrote:\n>> 2009/9/15 Björn Steinbrink <B.Steinbrink@gmx.de>:\n>> > Just don't use patch(1), there's no sane reason to do that, you're\n>> > sacrificing all of what git can offer there.\n>>\n>> Oh, yes there is, specially for newcomers used to patch, and how it\n>> handles conflicts.\n>\n> Sooner or later you'll hit a merge conflict anyway, and conflict markers\n> aren't that hard to understand, and IMHO are easier to handle than .rej\n> files, as you get to edit everything in-place.\n>\n>> In this case, I happen to know that Howard is a refugee from CVS land\n>> (the moodle project in this case), and he is familiar with the output\n>> of patch if things go wrong.\n>\n> Uhm, CVS uses the same conflict markers that git uses.\n>\n>> It's not what I'd recommend to someone that is deep in git-land. But\n>> even myself (with a bit of code in git) sometimes use patch when\n>> git-apply tries to be too clever and I just want a damn .rej file to\n>> review and edit with emacs.\n>\n> Well, you likely shouldn't be using git-apply, which is plumbing, and\n> can't easily make use of the \"index\" information in git patches to do a\n> three-way merge instead of a \"stupid\" patch application. Instead use\n> git-am --3way to make git perform a three-way merge, leading to\n> conflicts instead of plain patch rejection.\n>\n> And in a case like Howard's, in which nothing is coming from outside the\n> repo, there's not even any reason to use am. It's already all in there,\n> so \"checkout -m\", \"stash/stash apply\" (uncommitted changes) and\n> \"cherry-pick\", \"rebase [-i]\" are way better than manually dealing with\n> format-patch + am or even apply.\n>\n> Björn\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"},{"id":"123285","messageId":"46a038f90909151453u5ead2eb5nebb46930a8e7277@mail.gmail.com","threadId":"20950","inReplyTo":"20090915203948.GA14652@atjola.homenet","subject":"Re: Commited to wrong branch","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2009-09-15T21:53:03Z","receivedAt":"2009-09-15T21:53:03Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"2009/9/15 Björn Steinbrink <B.Steinbrink@gmx.de>:\n> Sooner or later you'll hit a merge conflict anyway, and conflict markers\n> aren't that hard to understand, and IMHO are easier to handle than .rej\n> files, as you get to edit everything in-place.\n\nWhen git's diff3 gets confused trying to use ancestry, the conflict\nmarkers bring completely unrelated things that belong to the history\nof the file and not to the patch at hand.\n\nIt's not about the conflict markers but somewhat nonsensical proposed\n\"sides\" to the resolution.\n\n> Well, you likely shouldn't be using git-apply, which is plumbing, and\n> can't easily make use of the \"index\" information in git patches to do a\n> three-way merge instead of a \"stupid\" patch application. Instead use\n> git-am --3way to make git perform a three-way merge, leading to\n> conflicts instead of plain patch rejection.\n\nUm, you got your internals wrong. git-apply is what git-am uses.\n\ncheers,\n\n\n\nm\n-- \n martin.langhoff@gmail.com\n martin@laptop.org -- School Server Architect\n - ask interesting questions\n - don't get distracted with shiny stuff  - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"},{"id":"123287","messageId":"20090915223025.GB14652@atjola.homenet","threadId":"20950","inReplyTo":"46a038f90909151453u5ead2eb5nebb46930a8e7277@mail.gmail.com","subject":"Re: Commited to wrong branch","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-09-15T22:30:25Z","receivedAt":"2009-09-15T22:30:25Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.09.15 23:53:03 +0200, Martin Langhoff wrote:\n> 2009/9/15 Björn Steinbrink <B.Steinbrink@gmx.de>:\n> > Sooner or later you'll hit a merge conflict anyway, and conflict markers\n> > aren't that hard to understand, and IMHO are easier to handle than .rej\n> > files, as you get to edit everything in-place.\n> \n> When git's diff3 gets confused trying to use ancestry, the conflict\n> markers bring completely unrelated things that belong to the history\n> of the file and not to the patch at hand.\n> \n> It's not about the conflict markers but somewhat nonsensical proposed\n> \"sides\" to the resolution.\n\nThat's not git getting confused trying to use the ancestry, but git\nbeing unable to make use of the history. It has to use a fake common\nancestor, as using the true common ancestor would obviously mean that\nyou do a real merge, not a cherry-pick. Under some circumstances that\ncan lead to quite \"interesting\" conflicts, yeah, but IMHO still better\nto deal with than those .rej files, especially when you switch to diff3\nconflict marker mode (git checkout --conflict=diff3 -- file), which also\ncontains the version of the code that the \"common ancestor\" has.\n\n> > Well, you likely shouldn't be using git-apply, which is plumbing, and\n> > can't easily make use of the \"index\" information in git patches to do a\n> > three-way merge instead of a \"stupid\" patch application. Instead use\n> > git-am --3way to make git perform a three-way merge, leading to\n> > conflicts instead of plain patch rejection.\n> \n> Um, you got your internals wrong. git-apply is what git-am uses.\n\nNo, you didn't understand what I said. I said that _you_ shouldn't be\nusing git-apply. That \"git am\" internally uses \"git apply\" is a totally\ndifferent story. And with --3way, it doesn't even run just \"git apply <\npatch\", but uses \"git apply\" just to build a fake common ancestor and\ndoes a 3-way merge with git-merge-recursive.\n\nBjörn\n"}]}