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