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
?
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With