将更改移回主线

时间:2018-03-23 20:31:51

标签: git version-control

您好我正在尝试将我的更改从开发分支移回主线;没有所有增量提交显示在历史记录/日志中 我试图用樱桃挑选做,但我猜我做错了。

以下是我的分支机构的样子:

Branch Mainline :

commit A [introduced after I branched to dev from mainline]
commit B
commit C
.... so on

Branch  Dev:

Commit P  [not pushed to remote]
Commit Q  [not pushed to remote]
more than 10 different commits in between [pushed to remote dev branch]
Commit B [Based on mainline]

Required result in Branch Mainline:

Commit allDev [A single commit with everything from the dev branch after Commit B ]
Commit A [This might need a merge commit since overlapping code from dev]
Commit B
Commit C
... so on

如果我能在这里得到一些帮助,将不胜感激。

1 个答案:

答案 0 :(得分:0)

使用壁球合并。这将在分支中保留增量提交,并在master中创建一个新的大提交。假设您在feature分支上:

$ git checkout master
$ git merge --squash feature
$ git commit

根据git-merge docs

  

- 壁球

     

- 没有壁球

     

生成工作树和索引状态,就像发生了真正的合并一样(合并信息除外),但实际上并没有   进行提交,移动HEAD或记录$ GIT_DIR / MERGE_HEAD(导致   下一个git commit命令来创建合并提交)。这可以让你   在当前分支的顶部创建单个提交,其效果是   与合并另一个分支相同(或者在章鱼的情况下更多)。

     

使用--no-squash执行合并并提交结果。这个选项   可以用来覆盖--squash。