[英]How do I pull values from another branch onto my local branch?
I am new to git and I am running into the following issue- I created a branch 'Test' from develop.我是 git 的新手,我遇到了以下问题——我从开发中创建了一个分支“测试”。 I am trying to pull changes from branch 'Working' (which is also based on develop) onto my local branch.
我正在尝试将更改从分支“工作”(也基于开发)拉到我的本地分支。 I don't want any of my changes to affect develop or 'Working'.
我不希望我的任何更改影响开发或“工作”。 How would I do this?
我该怎么做?
I am not sure whether this is a merge or a rebase.我不确定这是合并还是变基。
Either will work, but the result is different.两者都可以,但结果不同。
git merge working
will create a single, new merge commit which combines the history of both branches. git merge working
将创建一个新的合并提交,它结合了两个分支的历史记录。 The commits are shared by both branches.git rebase test working^{commit} && git push. HEAD:test && git checkout test
git rebase test working^{commit} && git push. HEAD:test && git checkout test
will rebase, ie copy , the commits on working
to test
. git rebase test working^{commit} && git push. HEAD:test && git checkout test
将变基,即复制,提交working
到test
。 The commits are now duplicated and separate versions of the commits exist in both branches. The third option is to cherry-pick, which is similar to rebase, but switches source and destination.第三个选项是 cherry-pick,它类似于 rebase,但会切换源和目标。
git cherry-pick test..working
will cherry-pick, ie copy , the commits on working
and apply them to your test branch. git cherry-pick test..working
将 cherry-pick,即复制,提交working
并将它们应用到您的测试分支。 The commits are duplicated and separate in both branches. History after merge:合并后的历史:
D-E -- working
/ \
A-B-C \ -- development
\ \
F-G-----M -- test (M = merge commit)
History after rebase or cherry-pick: rebase 或 cherry-pick 后的历史:
D-E -- working
/
A-B-C -- development
\
F-G-C'-D'-E' -- test (C', D', E' = copied commits)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.