CQM
CQM

Reputation: 44278

Git, must pull, know there will be conflicts, but local version is irrelevant

I know that upon pulling there will be conflicts, but I already know that the repository version is better. How do I resolve all conflicts on the command line with a git command

something like $> git resolve conflict with theirs or something

Upvotes: 4

Views: 1600

Answers (4)

9000
9000

Reputation: 40894

Can you still merge your HEAD with remote without totally removing your changes, but always resolving conflicts in remote's favor:

git pull -s recursive -Xtheirs <remote-ref>

But beware — your changes will be partially saved, and partially overwritten. This may be OK if you expect them overwritten in one part of tree and kept in another, but be very careful with the resulting code, be sure to review it and compare it to the remote version.

Upvotes: 3

topek
topek

Reputation: 18979

By specifying the merge strategy you should be able to do this:

git fetch
git merge -s recursive -Xtheirs remotes/origin/branch_name

or

git pull -s recursive -Xtheirs origin master

Upvotes: 3

CB Bailey
CB Bailey

Reputation: 792627

If you don't want to keep your changes then pull is the wrong action. If the repository version is unequivocally better you can just fetch and reset.

E.g.

git fetch

# Assuming my branch was based on origin/master,
# throw my changes away.
git reset --hard origin/master

Obviously be careful with this, as you may lose uncommitted changes. You may want to do a plain git reset origin/master and remove your local changes carefully by hand.

Upvotes: 4

pomaxa
pomaxa

Reputation: 1746

Try to do

git clean
git pull

if not helped, then try

git reset --hard HEAD
git pull

Upvotes: 0

Related Questions