I'm trying to rebase a branch on top of master, something I've done a thousand times before. But today, it's not working:
> git status
On branch mystuff
Your branch and 'master' have diverged,
and have 6 and 2 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working directory clean
> git rebase
First, rewinding head to replay your work on top of it...
> git status
On branch mystuff
Your branch is up-to-date with 'master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
[a directory from the project]
nothing added to commit but untracked files present (use "git add" to track)
>
Everything starts like normal, but then Git finishes the rebase without putting any of my commits there; my branch mystuff ends up on the same commit as master.
The obvious conclusion would be that my commits are already in master somewhere. But they're not, I swear. I've gone back through the history. The commits are on a couple of other feature branches, but they're not in the history of master anywhere. (And I can tell they're not in master anyway by the state of the files when I have master checked out.)
So, if the commits aren't already in my upstream history, why else would git rebase
refuse to stack my commits on top?
Oddly enough, if I cherry-pick the commits onto master one-by-one, that works. And then I can move my mystuff branch to the end, and back master up to where it was. (But why would I need to do it that way?)
EDIT:
The documentation on git rebase
says this:
The current branch is reset to
<upstream>
, or<newbase>
if the--onto
option was supplied. This has the exact same effect asgit reset --hard <upstream>
(or<newbase>
).ORIG_HEAD
is set to point at the tip of the branch before the reset.The commits that were previously saved into the temporary area are then reapplied to the current branch, one by one, in order. Note that any commits in
HEAD
which introduce the same textual changes as a commit inHEAD..<upstream>
are omitted (i.e., a patch already accepted upstream with a different commit message or timestamp will be skipped).
This would be consistent with the behavior I'm seeing if the commits actually existed upstream...but they don't. And as mentioned in the comments, git rebase master
works correctly and applies all the commits. But git rebase
without master
doesn't, even though master is set as the upstream branch.
Configuration of my branches:
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "mystuff"]
remote = .
merge = refs/heads/master