Kieran
Kieran

Reputation: 251

Git Stash equivalent of --theirs

I'm fairly new to git via command line, but I've seen that you can use --theirs and --ours to resolve merge conflicts. Unfortunately, this seems to only work with git checkout. Is there a way to do a similar thing when using git stash pop / git stash apply? i.e. When I pop from the stash it creates a load of conflicts. Rather than resolve each one individually, is there a way to instantly resolve them all one way or the other?

Upvotes: 25

Views: 8830

Answers (2)

alex_c137
alex_c137

Reputation: 1904

In addition to @r3mus-n0x answer, you should provide the index of stash you want to check out. Then the fatal error should not occur.

$> git stash list
   stash@{0}: WIP on xxx: 466a845fe Fix: Deleted unnecessary comments

$> git checkout stash@{0} --theirs .

Confirmed with git-version 2.28.0

Upvotes: 23

r3mus n0x
r3mus n0x

Reputation: 6144

You can still use git checkout with the current directory as an argument:

git checkout --theirs .

Upvotes: 8

Related Questions