On 2016-01-15 10:06, Bram Moolenaar wrote: > I think most users will be in this situation: > > - Initially check out Vim from github: > > git clone https://github.com/vim/vim.git > > - Change a makefile to set some options, or change bigvim.bat to match > your Python version, etc. > > - Build Vim. > > So far so good. Now the Vim version on Github gets patches, the user > will want to simply sync to the latest version and keep his local > changes (assuming there are no merge conflicts). Now what is the git > command for that? > > A simple "git pull" results in the error "Your local changes to the > following files would be overwritten".
The simple way *is* 'git pull'. At least it's supposed to be; the aforementioned error implies that your assumption is false. Alas, in practice, 'git pull' can be unnecessarily stupid about what is and is not a conflict¹. The 'stash; pull; stash pop' answer will DTRT in many cases, and leave you with pieces from which you can safely reconstruct your previous state otherwise. The slightly safer answer is to commit your changes locally and then do a 'git pull --rebase' followed by 'git reset --soft HEAD^' to undo the commit. (¹ I'd swear I do pulls all the time with uncommitted changes. It may be this works only if locally modified files aren't affected by the pull.) On 2016-01-18 14:36, Bram Moolenaar wrote: > For that reason I have changed the instructions to something that should > always (always?) work: > > git stash > git pull > git stash pop You should probably note to skip steps 1 and 3 if you have no local changes. Otherwise the first will complain (but do nothing), and the second will either also complain, or might pop a previously saved stash. Alternatively, you could suggest to always 'git pull' by itself first, and then do the above iff a lone 'git pull' complains. > Well, you can still run into merge conflicts, and then you're in trouble > again. It's not easy to find out what to do, even just saying "I don't > care, just trhow away my local changes" does not have an obvious git > command. I would expect "git revert <filename>", but that doesn't work. 'git revert' undoes a commit. I have also often felt this was unfortunate naming :-). > "git checkout <filename>" sometimes works. Perhaps with "-f"? 'git checkout HEAD -- <filename>' (I have this aliased to 'discard'). You shouldn't need '-f', but sometimes you need the 'HEAD --' to disambiguate files and rev names. (Also, 'reset --hard HEAD', as noted... with no <filename>, if you want to throw out *everything*. I generally avoid that, however.) Another useful recipe is: git reset HEAD -- # remove conflict status from files with conflicts git checkout -p # interactively discard local changes, e.g. conflicts Note that the first does NOT modify the file contents, i.e. there will still be conflict markers in them. It just tells git to discard the flag that indicates that there are conflicts needing to be resolved. (Also, to remove them from the index. See manpage for gory details.) -- Matthew -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
