Reputation: 3
I've been working on a feature for a project on a branch that was created from master
, which is currently in review for merging. I'll call it dev
. In the meantime, I created a branch out of dev
which I'll call branch
.
While in review, dev
was found to need some changes, so I checked dev
back out, made the changes, and recommitted and pushed.
Now my copy of branch
is out of date with its source, dev
. How do I update it? Normally, I would just do a fetch, followed by a pull. When master
has changes, doing this causes my branch to pull in said changes, allowing me to stay up to date with the work of my peers. When I try to do this between my own branches, it says branch
is up-to-date, which is incorrect.
What am I missing?
Thanks.
EDIT: I ended up doing a rebase as Max Friederichs describes below. It does what I specified in terms of updating branch
with the changes from dev
. The reason I selected Jean Rostan's answer is because doing a rebase changes the workflow history of the git repository, but doing a merge as Jean suggested merges in the new stuff from the branch and leaves the workflow history alone -- good for when you want to see what happened when.
In reality, both solutions achieve the same thing, just with different effects on the workflow history.
Upvotes: 0
Views: 885
Reputation: 1146
If it's local branches only (which is your case), start by going on the branch you want to update:
git checkout branch
Then merge local changes from the target branch:
git merge dev
and it will merge dev
into branch
, that is to say update it.
When you do a pull, you retrieve upstream changes (in your remote repo); thus no changes are found if no changes were made on the branch branch
in your remote repo.
Upvotes: 2
Reputation: 599
You need to rebase
your branch
... branch so that it includes the latest changes you made to the dev
branch
git checkout branch
git rebase dev
This will momentarily put aside your changes on branch
, apply missing changes from dev
, then re apply your changes to branch
. Any conflicts need to be addressed at this time as well. You will need to force push if branch
was previously pushed.
Upvotes: 2