0

I was unable to explain why I had this message. I had a master branch, created a new branch, made some commits and wanted to merge them back onto master, which I would have expected to cause master to fast forward. Indeed test cases confirm.

However in my search for a solution I hit this post:

Git merge reports "Already up-to-date" though there is a difference

Can anyone explain why in this example the reporter explains there would be no fast forward?

Additional information I can think of:

  • I was not in a detached head mode.
  • I checked back out to master to merge new branch:

     git checkout -b new-branch
     git commit -am "changes to new branch"
     git checkout master
     git merge new-branch // expect fast forward but got the already up to date msg
    

In a simple test case I dont get the above - so something to do with the mess of the repo, but more importantly I dont understand the rationale of the comments in the above stack overflow link - which would seem on the face of it to possibly explain something related to my scenario?

Community
  • 1
  • 1
user2237076
  • 331
  • 3
  • 13
  • Is there a diference between the branches? Run "git diff new-branch master" to check. Have you created "new-branch" (executed "git checkout -b new-branch") with the "master" branch checkouted? – Marcelo Ávila de Oliveira Apr 14 '16 at 13:11
  • ok, ignoring what I have done - I dont get the explanation in the post I linked to - surely (answer no. 7) would do a fast forward? – user2237076 Apr 14 '16 at 18:48
  • If the branch you’re trying to merge is a parent of your current branch than certainly you will receive the "already up-to-date" message. On the other hand, if your current branch is a parent of the branch you're trying to merge than certainly you will receive the "fast-forward" message. Other way, you'll have a merge. – Marcelo Ávila de Oliveira Apr 15 '16 at 00:48

1 Answers1

0

I assume you did something like this, based on master:

$ git checkout -b newBranch
... edit some files ...
$ git commit -a
$ git merge master
Already up-to-date.

Now, git reports nothing to merge, because you are trying to merge changes from master to newBranch.

Try merging from newBranch to master instead, e.g.

$ git checkout master
$ git merge newBranch
jil
  • 2,601
  • 12
  • 14