“This branch is 1 commit ahead, 1 commit behind master” in Github while using “A successful Git branching model”

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.

  • How can I overlay private files/folders over a public GitHub project working copy (and keep them under separate version control)?
  • File and directory permissions on a cloned github repository
  • linked local repo to incorrect github account
  • GitHub clone from pull request?
  • git permission denied but for different user
  • Git or anyother tools, creating a release from multiple tags in different repos
  • Git merge accidental commit to development branch
  • Reset GitHub login when using composer install
  • 3 Solutions collect form web for ““This branch is 1 commit ahead, 1 commit behind master” in Github while using “A successful Git branching model””

    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.

    Because you are using --no-ff every single mere will be a different commit. When you merge relese-0.0 into develop and into master the merge commits will be different. Here is how it looks like:

    commits

    As you can see the develop branch has one commit (Merge release 0.0 into develop) which is not in (not reachable from) the master and the master branch has one commit (Releasing v0.0) which is not in the develop branch. And that’s what gihub says with that message and it is totally fine (the contents are the same, but the commits different).

    If you would like to use git flow you should take a look at https://github.com/nvie/gitflow, which will help you a lot.

    Git Baby is a git and github fan, let's start git clone.