{"thread":{"id":"26657","subject":"why is merging with unstaged changes allowed when rebasing is not?","startedAt":"2011-03-04T16:32:19Z","lastAt":"2011-03-07T02:38:37Z","messageCount":3,"participants":["Christian Halstrick","Junio C Hamano","Neal Kreitzinger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"162773","messageId":"AANLkTi=dnyaPTX0Y43nbAGp46NtscKT3a2idxEhkreMm@mail.gmail.com","threadId":"26657","inReplyTo":null,"subject":"why is merging with unstaged changes allowed when rebasing is not?","fromName":"Christian Halstrick","fromEmail":"christian.halstrick@gmail.com","sentAt":"2011-03-04T16:32:19Z","receivedAt":"2011-03-04T16:32:19Z","isPatch":false,"sender":{"key":"christian.halstrick@gmail.com","avatar":"https://gravatar.com/avatar/3598bf518644c7dc32d4dcd8e0554b6a313e12103011862402c83ae2854203ce?d=mp&s=160"},"body":"Isn't it inconsistent that I can merge with unstaged changes in my\nwork-tree but not rebase? I agree that both should fail if the\noperation would have to touch the file which has unstaged changes. But\nif not - why don't we allow the rebase? (Is it just because we\ntechnically do a \"git reset --hard\" during the rebase which fails on\nunstaged changes?). Here is how tried it out:\n\ngit init\ntouch a b\ngit add a b\ngit commit -m initial\necho \"a-master\" >> a\ngit commit -a -m \"modified a on master\"\ngit checkout -b side HEAD~1\ntouch c\ngit add c\ngit commit -m \"added c on side\"\necho \"b-side\" >> b\n# git rebase master -> would fail complaining about unstaged changes\n# git merge master ->  would not fail\n\nEven a 'git checkout master; git cherry-pick side' works well (but\nupdates the wrong branch)\n\nCiao\n  Chris\n"},{"id":"162781","messageId":"7vmxla7oxl.fsf@alter.siamese.dyndns.org","threadId":"26657","inReplyTo":"AANLkTi=dnyaPTX0Y43nbAGp46NtscKT3a2idxEhkreMm@mail.gmail.com","subject":"Re: why is merging with unstaged changes allowed when rebasing is not?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-04T17:53:10Z","receivedAt":"2011-03-04T17:53:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Halstrick <christian.halstrick@gmail.com> writes:\n\n> Isn't it inconsistent that I can merge with unstaged changes in my\n> work-tree but not rebase?\n\nBecause people who wrote rebase didn't bother; it is too cumbersome to\ncheck all the possibly affected paths beforehand while replaying multiple\nchanges.\n\nPatches welcome ;-).\n"},{"id":"162893","messageId":"4D74452D.2010104@gmail.com","threadId":"26657","inReplyTo":"AANLkTi=dnyaPTX0Y43nbAGp46NtscKT3a2idxEhkreMm@mail.gmail.com","subject":"Re: why is merging with unstaged changes allowed when rebasing is not?","fromName":"Neal Kreitzinger","fromEmail":"nkreitzinger@gmail.com","sentAt":"2011-03-07T02:38:37Z","receivedAt":"2011-03-07T02:38:37Z","isPatch":false,"sender":{"key":"nkreitzinger@gmail.com","avatar":null},"body":"On 3/4/2011 10:32 AM, Christian Halstrick wrote:\n> Isn't it inconsistent that I can merge with unstaged changes in my\n> work-tree but not rebase? I agree that both should fail if the\n> operation would have to touch the file which has unstaged changes. But\n> if not - why don't we allow the rebase? (Is it just because we\n> technically do a \"git reset --hard\" during the rebase which fails on\n> unstaged changes?). Here is how tried it out:\n>\n> git init\n> touch a b\n> git add a b\n> git commit -m initial\n> echo \"a-master\">>  a\n> git commit -a -m \"modified a on master\"\n> git checkout -b side HEAD~1\n> touch c\n> git add c\n> git commit -m \"added c on side\"\n> echo \"b-side\">>  b\n> # git rebase master ->  would fail complaining about unstaged changes\n> # git merge master ->   would not fail\n>\n> Even a 'git checkout master; git cherry-pick side' works well (but\n> updates the wrong branch)\n>\n> Ciao\n>    Chris\n\nfood for thought:\n\ngit-merge manpage: \"Warning: Running git merge with uncommitted changes \nis discouraged: while possible, it leaves you in a state that is hard to \nback out of in the case of a conflict.\"\n\nI would imagine that if its a bad idea for git-merge, its a really bad \nidea for git-rebase...\n\nv/r,\nneal\n"}]}