Git:将提交发送给另一个分支,这样我就可以工作并合并回来,而无需(非常慢)结帐? [英] Git: send commit to another branch so I can work and merge back, without (very slow) checkout?
问题描述
我有两个分支,主要
一个和我正在处理并行
版本的分支。
A - > B - > C(主)
\
- > E - > F(并行)
并行
分支将总是从 master
合并。总是。并修改它。
A - > B - > C - > D - > H(主)
\ \ *合并*
- > E - > F - > G - > J(并行)
如果我切换分支,这很容易做到。
但是,如果我正在处理并行
,我可以在不切换分支的情况下执行此操作吗? 切换问题是需要很长时间来回(我在 F
上,而master仍然在 A
上。然后,我想对master B
和 C
进行一些提交,然后将它们合并到 G
。我怎样才能做到这一点,没有切换分支?
要在两个分支上同时工作,请在并行克隆间进行推送。 / b>
#一次性设置:
new = parallel-master
git clone。 ../$new -b master
git remote add $ new ../$new
切换到master:
cd ../parallel-master
#工作提交提交lalala
切换回:
git push origin master
cd ../main
这就是所需要的, git merge
正常工作。如果你打算从并行到主从合并,只需在切换之前先按另一种方式,两种方式的工作方式相同。
I have 2 branches, the main
one and the one I'm working on a parallel
release.
A --> B --> C (master)
\
-> E --> F (parallel)
The parallel
branch will always merge from master
. Always. And modify upon it.
A --> B --> C --> D --> H (master)
\ \ *merge*
-> E --> F --> G --> J (parallel)
This is easy to do if I switch branches.
But, if I'm working on parallel
, can I do this without switching branches? The problem with switching is that it takes a long time to go back and forth (specially on Unity 3D)!
So say I'm on F
, while master is still on A
. Then I wanted to make few commits on master B
and C
then merge them into G
. How would I do it, again, without switching branches?
To work simultaneously on two branches, push between paralleled clones.
# one-time setup:
new=parallel-master
git clone . ../$new -b master
git remote add $new ../$new
Switch to master:
cd ../parallel-master
# work work commit commit lalala
Switch back:
git push origin master
cd ../main
and that's all it takes, git merge
works normally. If you're ever going to merge from parallel to master, just push the other way before switching, it works the same both ways.
这篇关于Git:将提交发送给另一个分支,这样我就可以工作并合并回来,而无需(非常慢)结帐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!