cYrus
cYrus

Reputation: 2617

Git apply stash using conflict notation

It may sounds weird, but sometimes during some quick-and-dirty hacks I would like to have the files changed to reflect both prior version and stashed changes after a git stash apply:

++<<<<<<< Updated upstream
 +stuff
++=======
+ more stuff
++>>>>>>> Stashed changes

This notation is used by Git to manually resolve conflicts; I'm not necessarily looking for that, what I want is just a way to have both versions in my editor without using any external merge tools.

Maybe this can be better obtained using a feature of the editor rather than Git itself, in that case I'm using Emacs.

Upvotes: 1

Views: 378

Answers (1)

Borealid
Borealid

Reputation: 98469

In git, the stash stack is actually a branch. That means anything you can do to a normal branch, you can also do to your stash: this includes merging with it!

So if you want any particular merge-specific behavior, just make it a merge with stash@{0} instead of a git stash apply.

If you just want to see the differences, you can git show the stash content the same way (or git diff, or any other git command).

Example: meld <(git show stash@{0}:path/to/file) <(git show HEAD:path/to/file)

Upvotes: 3

Related Questions