如何将我的本地未提交更改合并到另一个Git分支中? [英] How to merge my local uncommitted changes into another Git branch?
问题描述
我该如何在git中做到这一点:
我当前的分支是分支1,我做了一些本地更改。不过,我现在意识到我实际上是想将这些更改应用于branch2。有没有办法应用/合并这些更改,以便它们在branch2上成为本地更改而不在branch1上提交它们?
既然您的文件尚未在 branch1
中提交:
git存储
git checkout branch2
git stash pop
或
git stash
git checkout branch2
git stash list#检查在不同分支中创建的各种存储
git stash apply x #选择正确的一个
评论通过 benjohn (见 git stash
手册页):
当前未跟踪的(新添加的)文件,添加参数
-u
,所以:
git stash -u
How can I do this in git:
My current branch is branch1 and I have made some local changes. However I now realize that I actually meant to be applying these changes to branch2. Is there a way to apply/merge these changes so that they become local changes on branch2 without committing them on branch1?
Since your files are not yet committed in branch1
:
git stash
git checkout branch2
git stash pop
or
git stash
git checkout branch2
git stash list # to check the various stash made in different branch
git stash apply x # to select the right one
As commented by benjohn (see git stash
man page):
To also stash currently untracked (newly added) files, add the argument
-u
, so:
git stash -u
这篇关于如何将我的本地未提交更改合并到另一个Git分支中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!