git question

Everything that has to do with the forum on a technical level. Logins, posts, formatting ...
laserman
Posts: 138
Joined: Thu Sep 17, 2015 7:26 am

git question

Postby laserman » Tue Oct 25, 2016 10:56 pm

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"

OPFOR77
Posts: 208
Joined: Wed Apr 27, 2016 7:30 pm

Re: git question

Postby OPFOR77 » Tue Oct 25, 2016 11:34 pm

To your normal "git pull", add "-X ours" to keep local copies and "-X theirs" to keep the merging copies.
OPRF Fighter Jock and Dev

laserman
Posts: 138
Joined: Thu Sep 17, 2015 7:26 am

Re: git question

Postby laserman » Tue Nov 01, 2016 10:22 am

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.

OPFOR77
Posts: 208
Joined: Wed Apr 27, 2016 7:30 pm

Re: git question

Postby OPFOR77 » Tue Nov 01, 2016 4:44 pm

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".
OPRF Fighter Jock and Dev


Return to “Technical Questions”

Who is online

Users browsing this forum: No registered users and 4 guests