Git合并没有历史记录提交

时间:2013-11-28 08:06:50

标签: git version-control github git-merge git-pull

我希望在将其他分支合并到master时没有其他分支历史记录提交。我怎么能这样做?

我们知道:

git pull - rebase origin test#mean:only history commit no merge commit。

git pull - no-ff origin test#mean:history commit and merge commit。

git pull - 仅限ff 来源测试#意味着:只有历史记录提交没有合并提交。

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

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

进一步提问:

如果我使用“ - 壁球”,它将不会在合并时自动记录“xxxx的合并分支'xxx'或”xxxx的合并标记'xxx'。需要把它写在我的手上?

2 个答案:

答案 0 :(得分: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

答案 1 :(得分: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).

git pull - 壁球原点测试

没关系!