Reputation: 101
Here's my problem. I have a branch off master, and i made some changes. A little later my partner reverted a change they had made because it was breaking something. When i ran git fetch; git rebase master
master was fixed and everything was okay. But when I ran git fetch; git rebase my_feature
the my_feature
branch still had the same problems as before. How can i update the my_feature
branch so that it takes into account the reverted commit? Thanks!
Upvotes: 10
Views: 37374
Reputation: 10961
You first need to git fetch and git merge your master branch that is following the remote master branch. You can do this with git checkout master
then git pull origin master
. This will bring your master branch up to a place that is equilivant with the remote repository.
Then you will need to do the following to rebase your feature branch ontop of the new commits (a git revert is just another commit to a branch and should be treated the same as any other commit (with special concerns depending on the situation)):
git checkout my_feature
then git rebase master
.
This will rebase your feature branch ontop of the new local master branch which should be tracking the remote master branch.
Upvotes: 16
Reputation: 28268
If the master branch before had commits
(A) --> (B) --> (C) --> (D)
and the my_feature
branch was based on (D)
, which is now reverted so that (C)
is the latest commit on master, then you can rebase my_feature
onto (C)
by running
git branch my_feature.orig my_feature # optional, delete this branch when satisfied
git rebase --onto master $SHA1_OF_COMMIT_D my_feature.
Upvotes: 0
Reputation: 5018
Since you branched my_feature
off master
, you have to do a git rebase origin/master
while being on my_feature
branch.
Upvotes: 0