Reputation: 123670
I am attempting an interactive rebase against my current branch. Ie, I have a commit that fixes a typo, that I'd like to make into a 'fixup' on top of another commit.
Sometimes this works. Sometimes this gives a strangely formatted error message like:
# git rebase -i
You asked me to rebase without telling me which branch you
want to rebase against, and 'branch.myBranchName.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git rebase <upstream branch>').
See git-rebase(1) for details.
If you often rebase against the same branch, you may want to
use something like the following in your configuration file:
[branch "myBranchName"]
remote = <nickname>
merge = <remote-ref>
rebase = true
[remote "<nickname>"]
url = <url>
fetch = <refspec>
See git-config(1) for details.
If I tell git the branch to rebase against (the current branch) it fails with:
# git rebase -i myBranchName
(my editor opens up with 'noop', which I believe is git telling me 'no op' in place of an actual error message). I'll quite the editor and get:
Successfully rebased and updated refs/heads/myBranchName.
How can I see the changes in my current branch in my editor, and mark it as fixup?
Upvotes: 3
Views: 3557
Reputation: 36859
I guess your situation is as follows?
-A-B-C----D----(HEAD)
\----Af
with Af
being the fixup-commit for A
And you want it to become
-(A+Af)-B-C-D--(HEAD)
For this scenario I would try the following:
>> rebase <Af> # where <Af> is the SHA1 of commit Af
your history would become
-A-Af-B-C-D----(HEAD)
And then
>> rebase -i <A>^ # A^ is the commit that came before A
It sould show you the interactive pick/squash view that enables you to squash A
and Af
together.
Upvotes: 0
Reputation: 38762
Maybe you want git rebase -i --autosquash origin/myBranchName
?
Argument of git-rebase is the point from where to start rewriting the history. It operates on the currently checked out branch.
Upvotes: 0
Reputation: 4054
git-rebase -i
is an operation that is applied to a number of commits.
So, if your current branch is
A-B-C-D
and you want to, for instance, merge A and C commits, you need to run (given A is the top commit)
git rebase -i HEAD~3
This means "rebase three top commits on the current branch" and "start from commit HEAD - 3".
Upvotes: 4