V
V
Vladimir Denisov2017-08-19 16:37:53
git
Vladimir Denisov, 2017-08-19 16:37:53

How to make a common commit when merging the devTest branch and the master branch?

I have a question about working with git
For example, there are 2 branches (master and devTest)
In the master branch there is only 1 commit (start), and in the branch (devTest) 5 commits (step1, step2, ... step5)
All changes from ( step5) upload to the master branch and commit the resulting merge of branches, for example (production1)
But the problem is that if you go to the (master) branch and do (git merge devTest), then all commits from the (devTest) branch will be available in ( master)
And I need only 2 commits in the (master) branch: (start), which was there initially and (product_v1)b7331ec73dc64231bb8a539b632312c9.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Movchan, 2017-08-19
@Alexander1705

This is called fast forward . If the branch you merge into has no commits since the branch, git will not create a new commit with two ancestors, but simply rebase the old branch onto the latest commit of the new branch. (a branch is just a pointer to a commit).
If you want to disable this behavior, just dogit merge --no-ff <branch_name>

X
Xeli, 2017-08-19
@Xeli

You need to use such a chip as the --squash parameter (squash commits) of the rebase function. The meaning of this function is that small commits will be merged into one large one, then a merge with master will be performed. After that, the development branch can be deleted. The result should be 3 commits on the master branch. One first initial, second "flattened" result, and third merged result of the master's first commit with the "flattened" commit. when you rebase the development branch, it will be ahead of the master and you will need to merge master with the migrated "flattened" branch.
Details here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question