Reputation: 16025
This is odd. There's apparently some difference between rebasing against my local develop
branch, and the remote develop
branch. Here are some details:
So let's say I have a feature branch, feat
, which I've been rebasing from time to time:
git pull --rebase origin develop
This is working fine. But now I'm done and ready to squash my commits and I noticed a big difference between:
git rebase -i origin develop
and
git rebase -i develop
The former brings up my editor with a HUGE list of commits from develop
, none of them are my changes on feat
. It also switches me to the develop
branch. The latter brings up my editor with just my commits on feat
and does not switch me to my local develop
branch.
Is git rebase -i origin develop
actually switching me to my local develop
and then rebasing against the remote? Am I supposed to git checkout develop; git pull
first, then git checkout feat; git rebase -i develop
?
Upvotes: 3
Views: 3505
Reputation:
git rebase -i origin develop
is not the right syntax to use for rebase
.
git rebase -i develop
# or this, for the remote-tracking branch
git rebase -i origin/develop
are the correct syntaxes.
The official Linux Kernel Git documentation for git rebase
says that this is the general syntax (omitting some options for clarity):
git rebase [-i] [<upstream>] [<branch>]
where <upstream>
is a branch:
<upstream>
Upstream branch to compare against. May be any valid commit, not just an existing branch name. Defaults to the configured upstream for the current branch.
When you use git rebase -i origin develop
, origin
is the name of your remote, not a branch. If you wanted to rebase against origin/develop
, you need to use the path separator /
:
git rebase -i origin/develop
As for your question:
Is
git rebase -i origin develop
actually switching me to my local develop and then rebasing against the remote?
It might be switching to your local develop
, but since the syntax isn't even valid, I'm not 100% sure. The reason I say maybe is because the behavior of rebase
when you pass a valid upstream branch and another branch is to checkout the second branch before rebasing against the first:
If
<branch>
is specified,git rebase
will perform an automaticgit checkout <branch>
before doing anything else. Otherwise it remains on the current branch.
Finally, git rebase -i develop
and git rebase -i origin/develop
could be different if your local develop
isn't update-to-date with your remote-tracking branch origin/develop
, like if you git fetch
and never merge updates into your local develop
.
Upvotes: 4