3

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
Patifon_Kakao
  • 41
  • 1
  • 4

1 Answers1

3

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
Enrico Campidoglio
  • 56,676
  • 12
  • 126
  • 154