git存储 - >将隐藏的变化与当前的变化合并 [英] git stash -> merge stashed change with current changes

查看:297
本文介绍了git存储 - >将隐藏的变化与当前的变化合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对分支做了一些修改,意识到我忘记了我对该分支进行了一些其他必要的修改。我想要的是将我的隐藏更改与当前更改合并的方法。



有没有办法做到这一点?

为了方便起见,我最终放弃并承诺我当前的变化,然后我隐藏的变化,但我宁愿让他们一举陷入。

运行 git stash pop git stash apply 本质上是一个合并。您应该不需要提交当前的更改,除非在工作副本中更改的文件也发生了更改,在这种情况下,您会看到以下错误消息:

 错误:您对以下文件的本地更改将被合并覆盖:
file.txt
请在提交您的更改或隐藏它们,然后才能合并。
中止

在这种情况下,您无法将存储应用于当前的更改一步。如果你真的不需要两次提交,那么你可以提交更改,应用存储,再次提交并压缩这两个提交,使用 git rebase ,但这可能会更麻烦这是值得的。


I made some changes to my branch and realized I forgot I had stashed some other necessary changes to said branch. What I want is a way to merge my stashed changes with the current changes.

Is there a way to do this?

Its more for convenience, I eventually gave up and committed first my current changes, then my stashed changes, but I would have preferred to get them in with one fell swoop.

解决方案

Running git stash pop or git stash apply is essentially a merge. You shouldn't have needed to commit your current changes unless the files changed in the stash are also changed in the working copy, in which case you would've seen this error message:

error: Your local changes to the following files would be overwritten by merge:
       file.txt
Please, commit your changes or stash them before you can merge.
Aborting

In that case, you can't apply the stash to your current changes in one step. You can commit the changes, apply the stash, commit again, and squash those two commits using git rebase if you really don't want two commits, but that may be more trouble that it's worth.

这篇关于git存储 - >将隐藏的变化与当前的变化合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆