[英]Git: branched off but parent branch has changed
Here is my scenario: 这是我的情况:
git checkout master
git pull
Now master
is up to date. 现在,
master
是最新的。
We create a new branch and switch to it: 我们创建一个新分支并切换到它:
git branch test
git checkout test
As of this point, test
and master
should be identical, with test
being a local branch not visible to remote/origin
. 至此,
test
和master
应该是相同的, test
是对remote/origin
不可见的本地分支。 (Correct me if this is wrong, but I see no reason why it should be) (如果这是错误的,请更正我,但我认为没有理由这样做)
Now, somewhere along the way, master
is merged with additional branches that affect files that you are working on locally in test
. 现在,在此过程中的某个地方,
master
与其他分支合并,这些分支会影响您正在test
本地处理的文件。 My question is: 我的问题是:
Aside from git stash
ing the changes so far, deleting the local test
branch, and branching off from master
again , what is the best way to merge the new changes from master
into the local test
branch? 除了
git stash
到目前为止的更改,删除本地test
分支并再次从master
分支之外,将新更改从master
合并到本地test
分支的最佳方法是什么?
As you already mentioned your could merge master
into test
by 正如您已经提到的,您可以通过以下方式将
master
合并到test
git checkout test
git merge master
which will collect the changes on master
branch and apply them in one merge commit on test
. 它将在
master
分支上收集更改,并将它们应用于test
一个合并提交中。
Instead you could also run git rebase master test
which will reapply the commits in test
onto the new master
and give you a linear history. 相反,你也可以运行
git rebase master test
将重新在提交test
到新master
,并给你一个线性的历史。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.