Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

merge

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?

like image 509
MeesterPatat Avatar asked Oct 26 '15 09:10

MeesterPatat


People also ask

Why git merge says already up to date?

The message “Already up-to-date” means that all the changes from the branch you're trying to merge have already been merged to the branch you're currently on. More specifically it means that the branch you're trying to merge is a parent of your current branch.

Why does git say my master branch is already up to date even though it is not?

If the current branch is not outdated compared to the one you pull from, pull will say Already up-to-date. even if you have local changes in your working directory. git pull is concerned with branches, not the working tree — it will comment on the working tree only if there are changes which interfere with the merge.

How do I merge a develop into a feature branch in git bash?

First we run git checkout master to change the active branch back to the master branch. Then we run the command git merge new-branch to merge the new feature into the master branch. Note: git merge merges the specified branch into the currently active branch. So we need to be on the branch that we are merging into.


1 Answers

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 
like image 111
Maroun Avatar answered Sep 20 '22 08:09

Maroun