2013-11-28 239 views
3

我想在没有其他分支历史提交时,我将其他分支合并到主。我该怎么做 ?Git合并没有历史提交

,因为我们知道:

混帐拉--rebase产地检验#意味着:只有历史承诺没有合并提交。

git pull --no-ff来源测试#含义:历史提交和合并提交。

git pull -ff-only origin测试#意思是:只有历史提交没有合并提交。

我想“只合并提交”,怎么样?请。像这样:

https://github.com/torvalds/linux/commits/master enter image description here

进一步的问题:

如果我使用 “--squash”,它不会自动日志 “合并分支XXXX的 'XXX'” 或“合并时,合并标记“xxxx xxxx”。需要把它写在我的手上?

回答

1

我得到的答案:

--squash, --no-squash 
     Produce the working tree and index state as if a real merge happened 
     (except for the merge information), but do not actually make a commit or 
     move the HEAD, nor record $GIT_DIR/MERGE_HEAD to cause the next git commit 
     command to create a merge commit. This allows you to create a single commit 
     on top of the current branch whose effect is the same as merging another 
     branch (or more in case of an octopus). 

混帐拉--squash产地检验

这没关系!

2

请注意,您还可以配置在您合并自动壁球要合并的(如在this discussion)在提交的分支:

git config branch.<name>.mergeoptions --squash 

git config有:

branch.<name>.mergeoptions 

设置合并到分支<name>的默认选项。
语法和支持的选项与git-merge相同,但包含空白字符的选项值当前不受支持。

这样,您不必为git merge添加任何额外的选项。

正如在 “In git, what is the difference between merge --squash and rebase?” 所提到的,虽然不会记录合并:

这将记录合并:

git config branch.<name>.mergeoptions --no-ff 
+0

非常好,THX。 – kangear

+0

看到“进一步的问题”,你能给我一些建议吗? – kangear

+1

@ kangear在你的情况下,no-ff会更适应:我已经答应了答案。 – VonC