
a :当前线上版本,需要不断修复 bug
b :来源于 a ,在 b 上面开发新模块
两个分支都要保留,不能删除。
在 a 上面更新代码以后,怎么也更新到 b ?
1 markowitz73 Sep 7, 2015 git checkout a & git pull & git checkout b & git rebase a |
2 orvice Sep 7, 2015 线上分支不应该直接在上面更新代码吧 |
3 ifconfig Sep 7, 2015 看看 git flow 流程, A 分支有 bug 应该新开一个 /hotfix 分支,修改上线后合并到 B 的 feature 分支 |
4 zioc OP |
5 markowitz73 Sep 7, 2015 via Android @zioc 我觉得我写的满足了你的需求。 |
6 malcolmyu Sep 7, 2015 似乎只能使用 rebase 了 |
7 cz208209 Sep 7, 2015 merge/rebase 有问题吗? 一楼的说的应该没问题吧 |
8 ivyshark Sep 7, 2015 切到 b 然后 rebase a |
9 adrianzhang Sep 7, 2015 这种开发模式是非常典型可以用 Git 最佳实践的。请参考: http://jiongks.name/blog/a-successful-git-branching-model/ |
10 muteZephyr Sep 7, 2015 一楼可行,不想切分支的话可以这么搞,效果相同: 在 b 上 git pull --rebase origin a |
11 otakustay Sep 7, 2015 一种做法是走 rebase git checkout b git rebase a 我觉得更好的做法是每一个 BUG 都从 a 拉出一个分支,这个分支开发完后同时 merge 到 a 和 b |
12 zioc OP |
13 woshifyz Sep 7, 2015 cherry-pick 看是不是你想要的 |
14 RoshanWu Sep 7, 2015 如果不是“同步”分支,建议 cherry-pick |
16 young Sep 7, 2015 难道 不是 git checkout a -> git merge b 吗? |
17 pyKun Sep 7, 2015 cherry-pick cherry-pick cherry-pick |
18 hyq Sep 7, 2015 少量提交可以用 cherry-pick 多一点的提交,看看能不能用 rebase |
19 TankyWoo Sep 7, 2015 如果能 merge --ff-only, 也可以这样 |
20 coolzilj Sep 7, 2015 建议楼主先熟悉一下 git 基础和 git-flow , 楼上说的 rebase/merge/cherry-pick 都可以, 用哪种方法完全取决去个人爱好, 洁癖用 rebase 强迫症用 merge 爱折腾用 cherry-pick |
21 NemoAlex Sep 7, 2015 在 b 上 merge a 就可以了啊,没有什么必要 rebase 。 cherry pick 会产生很多新的 commit ,更没有必要了。 |
23 nigelvon Sep 7, 2015 rebase 被玩坏了 |
24 ShadowStar Sep 7, 2015 建议用 merge rebase 可能会导致 non-fastforward cherry-pick 少量 commit 没问题,多了累 |
25 cz208209 Sep 7, 2015 没有争议的问题 为啥还讨论这么激烈 蛋疼 |
26 alexapollo Sep 7, 2015 git rebase -i <branch> 是正确的用法 |
27 zongwan Sep 7, 2015 On branch B 1. branch_b clean git merge branch_a 2. branch_b can not merge before commit git stash git merge branch_a * may need fix confilct then git stash pop 遇到不可合并的二进制文件,需要重新 git checkout file |