Reputation: 21015
I tried google, no help.
I got an active os project that keeps updating with good stuff and I'm developing on top of it,
So lets say I got the git repository of the project (lets call the current state x) and the current status is:
OS project
x
my project (added some y changes)
x -> y
Now OS project updated :
x -> z
and I wan't my project to contain z and look like
x -> z -> y
or
z -> y
Can someone explain how do I make it happen?
Upvotes: 1
Views: 133
Reputation: 13957
The simple method is to use the following two commands (after you've stached or committed your changes):
$ git fetch origin master
$ git rebase FETCH_HEAD
The first one fetches the changes in original repository from the remote named 'origin'. The second one moves your changes to the new remote HEAD.
The important thing to note here is that you use git fetch
and not git pull
. The latter is a fetch
followed by an automatic merge
. You don't want that.
In case you are looking for an alternative method, I always work on my separate branch. Then I can keep master equal to the maintainer's version, and I can keep rebasing my parallel branch. If there are other users of my branch I merge the master into it instead.
Upvotes: 2
Reputation: 16938
Assuming x, y, and z are branches (and x and z are really the same branch), and you have y checked out, you would do this:
git rebase z
What this does is replay all your commits from the point at which y was created, on top of z, to produce a new y for you. Note that you are changing history when you do this. That is to say, all the SHAs of your commits on y before the rebase are changed. This isn't a problem if you're the only one working on y. If you are working in a team, and multiple people have committed to y, then rebasing may be a bad idea. In this case, you can merge from z to y. That achieves your goal without changing history.
Upvotes: 1