I am working in a clean repo with just a single file. I am the only developer.
I want to do the develop-release-master workflow in A succesful git branching model so I did:
Note: Please bear in mind that I have the fast forward off by default, so consider all the merge
commands as merge --no-ff
.
My origin is Github.
In master branch:
git add .
git commit -m "Initial commit"
git push origin master
git checkout -b develop
In develop branch. I do a change to the file, then:
git add .
git commit -m "work in the file"
I am ready to release this as the version 0.0
git checkout -b release-0.0 develop
In release-0.0 branch. I add a version number to the file.
git add .
git commit -m "Bumped version 0.0"
I am ready to merge this release into master.
git checkout master
git merge release-0.0 -m "Releasing v0.0"
git tag -a 0.0 -m "Version 0.0"
... and into develop.
git checkout develop
git merge release-0.0 -m "Merge release 0.0 into develop"
Then I push both master and develop to Github
git push origin master
git push origin develop
When I check the develop branch in Github, it says:
This branch is 1 commit ahead, 1 commit behind master.
The master branch does not have a message like that.
What can I do to fix this? Both master and develop should be equal at this point, as they were merged both with release-0.0.
A branch can be both ahead and behind at the same time if you have made changes to your branch, and someone else have made changes on the default branch that you have not merged into your branch yet. I have a branch with 6 commits, and it shows 4 commits behind master in Bitbucket Cloud.
This means every locally created branch is behind. Before preceding, you have to commit or stash all the changes you made on the branch behind commits. Solution: Checkout your local Master branch git checkout master.
Master branch often reflects the code used in production. Hence, it is not a good practice to commit your work to the master branch. It is recommended to branch out or create a copy of the master branch in a different branch where you will commit your work.
No it won't be equal, since you have fast forward disabled by default. Every merge creates a new commit and the merge commit has a different id. So the merge commit in master is not the merge commit in develop. And hence develop has a commit not in master while master has a commit not in develop. Hence the message in develop.
As for the message not being there in master, that is because the message comes when a branch is compared to master. So if you compare master with master, the message is not necessary.
One solution is to enable fast forward and explicitly create merge commits in release and master and then keep fast forwarding develop. The other option is to rebase develop after every merge to master. How you want to go about it is purely your personal choice depending on your workflow and code.
Also the message being there isn't something you should be worried about as long as the code in the branches is exactly as you want.
Just to add to the other answers:
The original git-flow hasn't been in development since 2012, and it has been superseded by git-flow AVH edition in many places (including the Ubuntu repositories and Git for Windows).
One of the differences introduced by the AVH edition is that the final merge is that of master* into develop rather than that of release into develop.
This makes master a direct parent of develop and should eliminate one part of the message you see; only "1 commit ahead" should remain. It also makes it slightly easier to verify that master and develop have not diverged by accident.
* More precisely, it is the new tag (on master) that is merged into develop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With