fumeng
fumeng

Reputation: 1830

A successful rebase still shows others' commits in my PR

Just left Sourcetree and am now using terminal for git operations. I'm on my feature branch and I commit my changes from the last couple days. I push to remote.

I then run git rebase develop before i create my pull request to the develop branch. The rebase completes successfully, without merge conflicts or anything. I do nothing else except create the PR.

But my PR has other commits from other developers. Why is that? I'd expect that after a rebase that I'd only see my changes. Did I miss a step after running git rebase develop?

Upvotes: 0

Views: 1368

Answers (1)

eftshift0
eftshift0

Reputation: 30277

If you started working from another developer's branch (for example, you depended on changes that another developer is working on and they are still in the process of approval), you need to be extra careful to not move those revisions along with yours when you are rebasing... unless you know what you are doing.

Suppose that the other developer rebased their branch. Now you are standing on revisions that are not relevant to the work of the other feature branch.

How do you deal with this? You need to tell git what not to rebase. Say the last revision of the work of the other developer's branch is X in your branch:

git rebase --onto develop X my-branch

That should get rid of those revisions.

PS I read in the comments that you did not start from another developer's branch? Then I would ask: did anybody force-push into develop branch? (I am assuming your develop branch is in sync with the upstream develop branch, by the way).

Upvotes: 1

Related Questions