Git merge with --no-ff and --squash

I am using git thread to manage branches in my repo as described in: http://nvie.com/posts/a-successful-git-branching-model/

Thus, the sequence of commands that I should use will be as follows:

git checkout mybranch git pull --rebase origin develop git checkout develop git merge --no-ff mybranch 

However, there is one thing that I would like to do differently, in some cases:

I would like to save all my commits in my function branch ( mybranch ), but when merging (or crushing) they merge into one diff when merging into develop .

So, I think the sequence of commands should be:

 git checkout mybranch git pull --rebase origin develop git checkout develop git merge --no-ff --squash mybranch 

Will I really do something wrong if I need to combine --no-ff with --squash ?

I hesitate to try this because crush and save history are orthogonal requirements - see Twisting all my commits (including merges) into one commit without changing history

My consideration is that I want to keep history on one branch ( mybranch ) and suqash on another branch ( develop ) β†’, because these actions are performed on separate branches, this is normal.

+6
source share
1 answer

I tried combining --squash and -no-ff together and got:

 fatal: You cannot combine --squash with --no-ff. 

A git merge is basically squash. After resolving conflicts, it will appear as one commit for development. The difference in the revision of the merger is the result of conflict resolution. And yes, the changes on my border are saved. Just do "gitk mybranch &". after merging for verification.

In addition, the Shadow is correct. Do not be afraid. Create a new branch, play and see what the results are.

Damage was done in the "git pull -rebase origin develop" command.

Answer (assuming you have a local origin / development based branch):

 git checkout develop git pull git merge --no-ff mybranch 
+1
source

Source: https://habr.com/ru/post/946139/


All Articles