简体   繁体   中英

git rebase master results in master commits on top of branch commits

I'm working in a branch that was branched off master awhile ago. Since then, a number of features have been added to master that I would like to pick up in my branch. In the past, I've used git rebase master to rebuild my branch by replaying the commits in my branch on top of master. However, this currently isn't working as it should.

Here's what I'm doing

my-branch shows 63 commits ahead, 10 commits behind master - on github
git checkout master
git pull
git checkout my-branch
git rebase master my-branch

During the rebase, I hit only one merge conflict which is easily fixed. After the rebase finishes, I notice that some files reflect what is in master not my-branch . I can't, for the life of me, figure out what I'm doing wrong. Is this caused by the fact that the branch is both ahead and behind master? This seems like a fairly common situation, so I don't feel that it would break the rebase workflow.

I've also tried doing a git merge, which results in the exact same end state for my-branch .

-- Edit 10/18/19 --

I've narrowed the problem down to the following, which I didn't see until digging deeper.This is what happened

It turns out the changes in my-branch were merged into master a few months ago. After that, another branch absent of those changes was merged into master, effectively removing the changes. This means the commit that those changes are in isn't in the commit list for the rebase. I thought I saw the commit in the list, but the problem was it was a very generic message that I simply overlooked. Since this issue doesn't seem to be a problem with git or how I was using rebase, I'm going to accept the current answer and leave it here for future reference.

If your branch was started off from master, what you should run is (after having checked out your branch, as you do in the instructions):

git rebase master

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM