将隐藏项应用于其他分支 [英] Apply stash to different branch
问题描述
我不小心在错误的分支上工作.现在,我要将所有更改都转移到正确的分支.
I was accidentally working on the wrong branch. Now I want to transfer all my changes to the correct branch.
如果我存储更改并将它们应用到正确的分支上,它将只会将未提交的更改添加到正确的分支,还是将错误分支中不存在的每个更改/提交添加到正确的分支中?
If I stash the changes and apply them on the correct branch, will it only add the uncommitted changes to the correct branch or every change/commit from the wrong branch that doesn't exist on the correct branch?
例如
错误的分支具有:
-
提交
Commit a
未提交的更改b
正确的分支机构有
- 提交c
如果我在错误的分支上执行git stash并在正确的分支中git应用stash,它将把commit转移到正确的分支吗?
If I do git stash on the wrong branch and git apply stash in the correct branch, will it transfer commit a to the correct branch?
推荐答案
我将执行一次存储,然后重置(混合操作,这样您就不会丢失更改)一个提交,存储该提交,然后更改为正确的分支,然后弹出两个藏匿处.
I would do one stash, then reset (mixed so you don't lose the changes) the a commit, stash that, then change to the correct branch and pop both stashes.
git stash save "b"
git reset HEAD~
git stash save "a"
git checkout correct-branch
git stash pop
git commit -m "a"
git stash pop
这篇关于将隐藏项应用于其他分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!