- Originally, you branched off of develop:
a -- b develop
\
f -- g your_branch
- Next, someone else branched off of develop, and merged branch1 back into develop before you did. Now develop is in a different state compared to you first branched off of it.
a -- b -- c d develop
\ \ /
\ d -- e branch1
\
f -- g your_branch
- In order to have the features contained in branch1 in your feature branch you need to rebase on develop.
a -- b -- c d develop
\ /
d -- e branch1
- The solution is rebasing your changes onto the new state of develop. This is done by taking off your changes, fetching the latest state of develop, and then replaying your changes back onto that new state of develop - done.
a -- b -- c d develop
\ / \
d -- e \ branch1
\
f -- g your_branch
First, checkout out develop and make sure that your version (local) is the same as the remote (origin) version. Run git status and look for the message your_branch is up-to-date with origin/your_branch. If not, make it so by
git reset --hard origin/developNote that this is going delete all changes you may have (accidentally?) added to branch develop. But if that's not a problem you can just go ahead. Now change back to your branch and start the rebase process by
git rebase developThis hopefully will have no conflicts. If so, run again git status. That likely returns Your your_branch and 'origin/your_branch' have diverged, and have x and y different commits each, respectively. That's a problem. Now you need to re-write history by forcing a push.
git push --force-with-leaseand run git status again. Confirm that the local and remote version of that branch do not diverge anymore, et voila.