Git merge develop into feature branch outputs "Already up-to-date" while it's not
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
?
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
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
git pull origin develop
Since pulling a branch into another directly merges them together
git fetch && git merge origin/develop