Page 1 of 1

git question

Posted: Tue Oct 25, 2016 10:56 pm
by laserman
Hi!

How can I stop git from messing up my files with entries like:

Code: Select all

<<<<<<< HEAD


what I'd prefer is an interactive question or a default setting to always overwrite the local file
when I do "git pull"

Re: git question

Posted: Tue Oct 25, 2016 11:34 pm
by OPFOR77
To your normal "git pull", add "-X ours" to keep local copies and "-X theirs" to keep the merging copies.

Re: git question

Posted: Tue Nov 01, 2016 10:22 am
by laserman
thank you!

often I have to commit before I'm allowed to pull:

Code: Select all

git pull -X theirs
Aktualisiere f40040f..ed0edf8
error: Your local changes to the following files would be overwritten by merge:
   ...
Please, commit your changes or stash them before you can merge.
Aborting


that's ok for computers where I only pull and never push.
But in case I would push, I would have a unwanted commit in the git history.

Re: git question

Posted: Tue Nov 01, 2016 4:44 pm
by OPFOR77
If you're okay with getting rid of the changes (I.e. Resetting everything locally so there's no commit), you can get rid of that message by doing a "git checkout -- ./"

If you want to keep the changed files and add them back in after the pull (so still no commit), do a "git stash", do your pull, then "git stash pop".