문제

Say we have this situation:

       master
         |
A--B--B--D--E--F--G
                  |
                test

Then we merge test into master. Are commits E and F preserved in the new master branch?

That is, does it now lok like this (option A):

                master
                  |
A--B--B--D--E--F--G
                  |
                test

or like this (option B):

          master
            |
A--B--B--D--G
            |
          test

Sorry if this has already been asked, I couldn't find it. Also, the example in ProGit book is with only one commit ahead (in my example that would be E), which doesn't tackle a situation like this.

도움이 되었습니까?

해결책

What happens it option A: commits are preserved. In case of a fast-forward merge the history is not modified at all, only the master branch points at a different commit. That's all.

다른 팁

You get a fast forward merge (option A) and the reason to begin with is because there is only a single line of commits between master and test before the merge. If there was a branch between master and test, it would not be a fast forward merge any more.

I would suggest reading this for a good overview on how branching and merging works in git - you need to be really clear on how this stuff works when using git.

Option A is what happens. Sometimes people want to preserve the branch point and will force git to create a new merge commit.

git merge --no-ff test

This depends on the workflow you want to follow for development.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top