Git 使用冲突符号应用存储

发布于 2025-01-08 12:21:25 字数 355 浏览 3 评论 0原文

这可能听起来很奇怪,但有时在一些快速而肮脏的黑客攻击中,我希望更改文件以反映先前版本和 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心的位置 2025-01-15 12:21:25

在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 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文