I have my own
$ git config --global merge.ff only
fatal: Not possible to fast-forward, aborting.
I will use an example to illustrate some alternatives.
Assume you have made the following two "Develop commit" commits on the
develop branch, while there were two commits being made to the
* c302cd7 - (HEAD, develop) Develop commit 2 * 0a1fad1 - Develop commit 1 * fcf19a0 - Common commit
Alternative 1: git merge
git checkout master git merge develop
This would result in a history looking like this:
* e33bcaf - (HEAD, master) Merge branch 'develop' |\ | * c302cd7 - (develop) Develop commit 2 | * 0a1fad1 - Develop commit 1 * | 784442c - Master commit 2 * | 03c7803 - Master commit 1 |/ * fcf19a0 - Common commit
As I understand, you do not want this. You want to avoid the merge commit (
e33bcaf in the example above)
Alternative 2: git merge --squash
This approach will take all the changes from the
develop branch and bundle them together into one squash commit.
git checkout master git merge --squash develop git commit #enter apporpriate commit message describing the changes from develop branch
History will look like:
* 2fd2acc - (HEAD, master) Develop branch squash commit * 784442c - Master commit 2 * 03c7803 - Master commit 1 * fcf19a0 - Common commit
Alternative 3: git rebase
You can let git try to reproduce the same changes that you made on the
but starting from the latest version of the master branch instead. Note that this is not
a good idea if
develop is a published branch which others are using. But if
is just your own local branch, this is okay.
git checkout develop git rebase master
History will look like the following. If you want to, after this, you can merge
master branch and that merge will be a fast forward.
* f1e329c - (HEAD, develop) Develop commit 2 * 066affd - Develop commit 1 * 784442c - (master) Master commit 2 * 03c7803 - Master commit 1 * fcf19a0 - Common commit
Note that for all the three alternatives, you may have to resolve merge conflicts if there are any.