Git 使用冲突符号应用存储
这可能听起来很奇怪,但有时在一些快速而肮脏的黑客攻击中,我希望更改文件以反映先前版本和 git stash apply 后隐藏的更改:
++<<<<<<< Updated upstream
+stuff
++=======
+ more stuff
++>>>>>>> Stashed changes
此表示法由 Git 使用手动解决冲突;我不一定要寻找这个,我想要的只是一种在编辑器中拥有两个版本而不使用任何外部合并工具的方法。
也许使用编辑器的功能而不是 Git 本身可以更好地获得这一点,在这种情况下我使用 Emacs。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在git中,存储堆栈实际上是一个分支。这意味着您可以对普通分支执行的任何操作,也可以对您的存储执行:这包括与其合并!
因此,如果您想要任何特定于合并的行为,只需将其与
stash@{0}
合并,而不是使用git stash apply
即可。如果您只想查看差异,您可以以相同的方式
git show
存储内容(或git diff
,或任何其他git命令)。示例:meld <(git show stash@{0}:path/to/file) <(git show HEAD:path/to/file)
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 agit stash apply
.If you just want to see the differences, you can
git show
the stash content the same way (orgit diff
, or any other git command).Example:
meld <(git show stash@{0}:path/to/file) <(git show HEAD:path/to/file)