Git merge no history commit

i want to have no other branch history commit when i merge other branch to master. how can i do it ?

as we know:

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-only origin test # mean: only history commit no merge commit.

i want to " only merge commit ", how ? pls. like this:

https://github.com/torvalds/linux/commits/master 在这里输入图像描述

further question:

if i use " --squash ", it will not auto log "Merge branch 'xxx' of xxxx" or "Merge tag 'xxx' of xxxx" when merge. need write it on my hand ?


Note that you can also configure the branch where you merge to automatically squash the commits you want to merge in (as in this discussion):

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

git config has:

branch.<name>.mergeoptions

Sets default options for merging into branch <name> .
The syntax and supported options are the same as those of git-merge, but option values containing whitespace characters are currently not supported.

That way, you don't have to add any extra option to your git merge .

As mentioned in "In git, what is the difference between merge --squash and rebase ?", that won't record a merge though:

This would record a merge:

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

i get answer:

   --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 --squash origin test

It's ok!

链接地址: http://www.djcxy.com/p/16024.html

上一篇: 从Netbeans推到Grit的Git

下一篇: Git合并没有历史提交