Git merge develop into feature branch outputs "Already up-to-date" while it's not

GitMerge

Git Problem Overview


I checked out a feature branch from develop called branch-x. After a while other people pushed changes to the develop branch.

I want to merge those changes into my branch-x. However if I do

git merge develop 

it says "Already up-to-date" and doesn't allow me to merge.

git diff develop shows that there are differences between branch-x and develop.

How do I merge develop into branch-x?

Git Solutions


Solution 1 - Git

You should first pull the changes from the develop branch and only then merge them to your branch:

git checkout develop 
git pull 
git checkout branch-x
git rebase develop

Or, when on branch-x:

git fetch && git rebase origin/develop

I have an alias that saves me a lot of time. Add to your ~/.gitconfig:

[alias]
    fr = "!f() { git fetch && git rebase origin/"$1"; }; f"

Now, all that you have to do is:

git fr develop

Solution 2 - Git

Step by step self explaining commands for update of feature branch with the latest code from origin "develop" branch:

git checkout develop
git pull -p
git checkout feature_branch
git merge develop
git push origin feature_branch

Solution 3 - Git

git pull origin develop

Since pulling a branch into another directly merges them together

Solution 4 - Git

git fetch && git merge origin/develop

Solution 5 - Git

Initially my repo said "Already up to date."

MINGW64 (feature/Issue_123) 
$ git merge develop

Output:

Already up to date.

But the code is not up to date & it is showing some differences in some files.

MINGW64 (feature/Issue_123)
$ git diff develop

Output:

diff --git 
a/src/main/database/sql/additional/pkg_etl.sql 
b/src/main/database/sql/additional/pkg_etl.sql
index ba2a257..1c219bb 100644
--- a/src/main/database/sql/additional/pkg_etl.sql
+++ b/src/main/database/sql/additional/pkg_etl.sql

However, merging fixes it.

MINGW64 (feature/Issue_123)
$ git merge origin/develop

Output:

Updating c7c0ac9..09959e3
Fast-forward
3 files changed, 157 insertions(+), 92 deletions(-)

Again I have confirmed this by using diff command.

MINGW64 (feature/Issue_123)
$ git diff develop

No differences in the code now!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMeesterPatatView Question on Stackoverflow
Solution 1 - GitMarounView Answer on Stackoverflow
Solution 2 - GitzdrsoftView Answer on Stackoverflow
Solution 3 - GitPaul-Arthur THIÉRYView Answer on Stackoverflow
Solution 4 - GitSebastian DiezView Answer on Stackoverflow
Solution 5 - GitLinga Swamy ParandhaView Answer on Stackoverflow