{"thread":{"id":"16930","subject":"Why can't git pull --rebase work if there are modified files?","startedAt":"2008-12-30T21:40:22Z","lastAt":"2008-12-30T23:09:09Z","messageCount":2,"participants":["skillzero@gmail.com","Thomas Rast"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"98997","messageId":"2729632a0812301340y735c3946weee55c9856d4e6a9@mail.gmail.com","threadId":"16930","inReplyTo":null,"subject":"Why can't git pull --rebase work if there are modified files?","fromName":"","fromEmail":"skillzero@gmail.com","sentAt":"2008-12-30T21:40:22Z","receivedAt":"2008-12-30T21:40:22Z","isPatch":false,"sender":{"key":"skillzero@gmail.com","avatar":null},"body":"If I have locally modified files and I try to 'git pull --rebase', it\nfails because of the locally modified files. If I don't use the\n--rebase option, it works (but generates a merge commit if I have\nlocal commits). Why does rebasing require an unmodified checkout? It\nseems like it should only stop if I something in the newly fetched\nchanges conflict with my local changes.\n\nI almost always have modified files in my checkout for things I'm\nworking on. I also often have a commit or two that haven't been pushed\nbecause I'm waiting until I get to a good point before pushing. If I\ndo 'git pull', I end up with a merge commit each time. That's why I\nwant to use --rebase, but for it to work, I have to git stash, then\nrebase then git stash pop.\n"},{"id":"99010","messageId":"200812310009.12052.trast@student.ethz.ch","threadId":"16930","inReplyTo":"2729632a0812301340y735c3946weee55c9856d4e6a9@mail.gmail.com","subject":"Re: Why can't git pull --rebase work if there are modified files?","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2008-12-30T23:09:09Z","receivedAt":"2008-12-30T23:09:09Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"skillzero@gmail.com wrote:\n> If I have locally modified files and I try to 'git pull --rebase', it\n> fails because of the locally modified files. If I don't use the\n> --rebase option, it works (but generates a merge commit if I have\n> local commits). Why does rebasing require an unmodified checkout? It\n> seems like it should only stop if I something in the newly fetched\n> changes conflict with my local changes.\n\nFirst you need to be aware that 'git pull --rebase' is conceptually\nthe same as 'git fetch && git rebase upstream', where 'upstream' is\nthe remote branch tracked by your current branch.  (The canonical\nchoice is upstream=origin/foo for a branch foo.)  git-fetch is of no\nfurther interest to the discussion, as it does not touch the working\ntree in any way.\n\ngit-rebase is not concerned with \"newly fetched changes\".  It\n*rewinds* your branch to the updated 'upstream' tip, and then\n*rebuilds* your commits on top of that.  This involves a lot of\nresetting and applying patches, which appears to be why it enforces a\nclean working tree.\n\nYou can use git-stash (see the man page) to temporarily save away your\nuncommitted changes, however.  Maybe you could even write a patch to\ngit-rebase that lets it automatically save and restore uncommitted\nchanges?\n\n> I almost always have modified files in my checkout for things I'm\n> working on. I also often have a commit or two that haven't been pushed\n> because I'm waiting until I get to a good point before pushing. If I\n> do 'git pull', I end up with a merge commit each time. That's why I\n> want to use --rebase, but for it to work, I have to git stash, then\n> rebase then git stash pop.\n\nYou could probably improve your workflow a lot by using topic\nbranches.  See the recently added gitworkflows manpage, also available\nat\n\n  http://www.kernel.org/pub/software/scm/git-core/docs/gitworkflows.html\n\nor, e.g., Tv's excellent introduction to git called \"Version Control\nfor Du^H^HDevelopers\":\n\n  http://eagain.net/blog/2008/08/11/ep-talk-videos.html\n\n(Pretty much the second half is about branch workflows, topic branches\nare explicitly introduced at ~44:15.)\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n\n"}]}