Home > database >  Develop branch X commits behind Main branch after successful Pull Request
Develop branch X commits behind Main branch after successful Pull Request

Time:05-19

My Develop branch is showing as 2 commits behind the Main branch after I made a pull request merging Develop into Main on GitHub. It's now suggesting to me to do a pull request and merge Main into Develop. I am the only person working on this project so no other commits from other team members could have happened to any branch during this time.

To retrace my steps:

  • In git I did a git pull on remote Develop branch to update my local Develop branch.
  • I created a Feature branch locally from Develop branch using command line git.
  • On Feature, I made 3 commits.
  • I then checkout my local Develop branch and merged it with Feature branch.
  • I then pushed Develop (with its 3 new commits) to remote Develop via git.
  • On GitHub I then created a pull request to merge remote Develop with remote Main with the 3 commits.
  • Main branch now has all my changes.
  • Develop branch on GitHub is saying it is 2 commits behind Main.

I'm confused as to why this is happening. My understanding is that Develop and Main on GitHub would be in sync (both in terms of code and in commits) after the pull request. Both branches are showing the same code however the commits are off. Any idea where I made a mistake in my process and should I pull request Main into Develop to fix this issue? It seems like a messy fix.

CodePudding user response:

  • On GitHub I then created a pull request to merge remote Develop with remote Main with the 3 commits.
  • Main branch now has all my changes.

There's a step missing here: someone (some human, most likely) must have accepted and executed the Pull Request. What did they do at this point? If they used the big green button labeled REBASE AND MERGE, the result you've seen is what you should expect. This is GitHub-specific; other repository hosting sites may behave differently.

Aside: Git branch names are case-sensitive. It's unwise to use mixed case here; use names like main and develop, not Main and Develop. Windows and macOS users may encounter problems from time to time by creating names like main while names like Main also exist. The problem here is that while Git is case-sensitive, Git sometimes stores the branch name as an OS-level file, and the default file systems on Windows and macOS are case-insensitive and therefore cannot store two different files named main and Main. Git gets confused by this and bad things happen.

  • Related