小编OLU*_*OLU的帖子

GIT:如何强制合并提交到祖先

在GIT中,我有两个分支和两个提交:

 A(master)---B(branch "topic")
Run Code Online (Sandbox Code Playgroud)
  • 分支'master'的HEAD是提交A.
  • 分支'主题'的HEAD是提交B.
  • commit A是提交B的父级

我想在"topic"分支中创建一个合并提交C(它将A和B作为父级).(我知道这看起来很奇怪,并且合并提交将为空.)

 A(master)---B---C (branch "topic")
  \-------------/
Run Code Online (Sandbox Code Playgroud)

我设法以太复杂的方式创建这个合并提交(见下文).有没有更简单的方法来创建此合并提交?

谢谢你的回答!


初始状态:

$ git init plop
Initialized empty Git repository in /tmp/plop/.git/
$ cd plop/
$ git commit -m "Initial commit (commit A)"  --allow-empty
[master (root-commit) a687d4e] Initial commit (commit A)
$ git checkout -b topic
Switched to a new branch 'topic'
$ git commit -m "Some work on my topic branch (commit B)" --allow-empty
[topic d4d1c71] Some work on my topic branch (commit B)
$ #OK, …
Run Code Online (Sandbox Code Playgroud)

git merge commit

13
推荐指数
1
解决办法
8140
查看次数

标签 统计

commit ×1

git ×1

merge ×1