1

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.

cYrus
  • 2,976
  • 6
  • 29
  • 47

1 Answers1

3

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)

Borealid
  • 95,191
  • 9
  • 106
  • 122
  • I don't want just to see the differences; when a conflict occurs the file is actually changed showing both versions, I'm looking for a similar behavior even without conflicts. I want both versions written in the file just like when I have to manually resolve the conflict. – cYrus Feb 21 '12 at 19:14
  • @cYrus Ah! Then see http://stackoverflow.com/questions/3122056/how-to-get-3-way-merge-in-git-on-non-conflict-merges – Borealid Feb 21 '12 at 19:16
  • Yes, maybe, but I don't want to replace the behavior of the merge command, and changing the attribute every time is quite tedious. – cYrus Feb 21 '12 at 19:25
  • @cYrus If you don't want the merge command to behave any differently from normal, then you're going to have to accept that it normally performs merges (rather than just leaving the mess up to you). – Borealid Feb 21 '12 at 19:26