git merge Already up to date when it is not

22,362

You may not want to merge, but rather to rebase. That is, take the commits you've made, the commits you added to branch development—the ones that were not there when you first did your clone, but are there now—and see what changes each one made in sequence; and apply those changes, again in sequence, on top of branch production.

(Some of them will probably not go in cleanly: changes to production that are not present in development will mean that some, maybe many, of the changes you made need to be modified to fit in. Worse, changing one of your changes will almost certainly affect more of your changes, so this rebase could be difficult.)

That said... "Up to date" does not mean the code is the same, by any means. It just means that the commit graph shows that there is nothing new to bring in. That, in turn, implies you (or someone else) already did the merge. The tree attached to the final merge (the result of the merge) is not what you want, but the only thing git can see is that the merge is done. See Why after merge does GIT say “Already upto date”, but differences between branches still exist? for an example involving git revert, for instance.

Share:
22,362
Warwick Hall
Author by

Warwick Hall

Updated on July 09, 2022

Comments

  • Warwick Hall
    Warwick Hall almost 2 years

    While working on a project using git and bitbucket.com, there are the following branches:

    master
    development
    uat
    production
    

    When I started the project work I took a git clone of development (thinking naturally that it contained the state of the art code). Months of work later, and now it turns out that the code in production branch (which is currently running in production) has a later version than the code I started with in development branch.

    When I attempt to:

    git checkout development
    git merge production
    

    it says "Already up to date". When I go:

    git diff production..development
    

    it spits out lots of changes that say production branch has code that is not in development branch. How can I make the production code merge with development code without wiping my months of work?

  • Admin
    Admin over 5 years
    rebase says the same thing .. face-desk