Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source branch behind target branch by n commits

In my project the master branch contains the released state and the development branch is where the development is done.

The project was initially imported from SVN into the master branch and then development branch was created. The project was worked on using the development branch.

After a while, I wanted to merge development with master but got a conflict. (I think I may have inadvertantly added a CHANGELOG file to the master branch) Github displayed a message like The source branch is 1 commits behind the target branch. Anyway, I decided to merge the master back into the development branch and that seemed to fix the problem. I was able to merge the development branch with the master.

A short while later I wanted to merge development to master a second time and got a similar message The source branch is 2 commits behind the target branch. This seems to indicate that my previous action did not solve the problem.

Why is my development branch behind the master branch? What do I have to do to get them back in sync?

The graph looks like this enter image description here

I'm obviously doing something wrong here but I don't understand what it could be.

like image 998
paul Avatar asked Dec 07 '25 05:12

paul


2 Answers

It is not recommended to merge master branch to development branch.

If you want to keep your development branch updated with master branch, you should use git rebase.

      A---B---C development
     /
D---E---F---G master

After you run either of the following commands:

git rebase master
git rebase master development

your commit history would be:

              A'--B'--C' development
             /
D---E---F---G master
like image 61
gzh Avatar answered Dec 08 '25 21:12

gzh


The graph looks odd: In the line Merge branch 'development' into 'master', the purple branch was mergen into master. But the red branch is the one marked as development. It looks like some other development branch was merged into master.

The message The source branch is 2 commits behind the target branch means there are two commits reachable from the target (master) branch but not from the source branch (development). I would guess these are the First prod release and Merge branch 'development' into 'master' commits, but we would need to see more of your repositories history to know for sure.

like image 22
kowsky Avatar answered Dec 08 '25 21:12

kowsky