Marcus Leon
Marcus Leon

Reputation: 56699

Git merge of remote branch reports “Already up-to-date” when there are new remote commits

We regularly run this merge:

git merge origin/feature-branch

It seems there is a lag where I can see the commit in feature-branch (using BitBucket) but the merge command returns Already up-to-date.. We have to wait around 10 minutes after the commit to successfully run the merge. Is there some cache that needs to be cleared to get the latest without waiting?


Update:

The solution is described below. Turns out there wasn't really any "lag" or cache. I guess in the past I sometimes ran git pull in between unsuccessful and successful merge attempts.

Upvotes: 0

Views: 871

Answers (2)

Sachin
Sachin

Reputation: 2922

git checkout feature-branch
git pull
git checkout Your-Branch
git merge feature-branch

If someone else is also working on your branch then

git pull Your-Branch
git checkout feature-branch
git pull
git merge feature-branch

Upvotes: 0

Marcus Leon
Marcus Leon

Reputation: 56699

Solution here was to run git pull first:

git pull
git merge origin/feature-branch

This blog post sorted me out. I had no idea that:

You may not have realised that git keeps a clone of your remote repositories on your machine ... origin/master is not on GitHub, it’s the clone of the remote master branch on your machine.

Thus had to do the git pull to update my "local" clone of origin/master. Then the merged worked!

Upvotes: 1

Related Questions