4

I am having a merge conflict when using git stash apply. How can I hard overwrite files using stash?
Something like that

git stash apply -Xours 
3
  • 2
    Please take look at this question. stackoverflow.com/questions/16606203/… Commented Aug 25, 2021 at 9:26
  • Try committing first? Commented Aug 25, 2021 at 9:26
  • I would suggest that this is one of many reasons for not using stash. Commented Aug 25, 2021 at 12:50

1 Answer 1

5

For the time being, git stash pop and git stash apply don't offer a way to automatically resolve conflicts.

From the documentation of git stash pop:

Applying the state can fail with conflicts; in this case, it is not removed from the stash list. You need to resolve the conflicts by hand and call git stash drop manually afterwards.

What you can do, however, is use git checkout to quickly resolve the conflicts by choosing one side.

Here's a bit from the Git Book:

The git checkout command can also take --ours and --theirs options, which can be a really fast way of just choosing either one side or the other without merging things at all.

In your case, you can simply run this after git stash apply:

git checkout --ours -- /path/to/conflicting/file 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.