RE: git rebase -i onto HEAD~n
- From
- Bisani, Alok <alok.bisani@credit-suisse.com>
- Date
- Feb 3, 2009, 16:15 UTC
- Message-ID
- <C5E2CAEE4A87D24DAB5334F62A72D1F43ADCA0@ELON17P32001A.csfb.cs-group.com>
- In-Reply-To
- <20090203154457.GA6859@atjola.homenet>
Show 26 quoted lines
>On 2009.02.03 15:32:35 -0000, Bisani, Alok wrote: >> Hi, >> >> Is it possible to use git rebase -i for the following use case, in a >> local branch? >> >> $ git reset --soft HEAD~3 >> $ # magically squash HEAD~2 & HEAD, ignoring HEAD~1 (which should be >> discarded) >> $ git commit -m "new commit replacing current HEAD~2 HEAD, without the >> commit HEAD~1 (to be discarded)" >> >> I get the error below. >> >> grep: /home/user/project/.git/rebase-merge/done: No such file or >> directory >> Cannot 'squash' without a previous commit > >It would be helpful if you told us what command you used, and what you changed in the editor. > >This should do: >git rebase -i HEAD~3 > >And in the editor: >pick HEAD~2 >squash HEAD
Sure. Here is the sequence of commands.
mkdir gittest; cd gittest/
git init
echo "one" > one.txt; git add one.txt; git commit -m "one"
echo "two" > two.txt; git add two.txt; git commit -m "two"
echo "bad" > discard.txt; git add discard.txt; git commit -m "discard"
echo "three" > three.txt; git add three.txt; git commit -m "three"
git rebase -i HEAD~3 # Leave editor for ~/gittest/.git/rebase-merge/git-rebase-todo with
squash 8df4c33 two
# deleted line with discard
squash 91f8267 three # And get this error
grep: /home/user/gittest/.git/rebase-merge/done: No such file or directory
Cannot 'squash' without a previous commitI guess the error could be introduced after commit -m "two" is first squashed, leaving commit -m "three" parentless, in the (no branch) branch?
Best regards, Alok
============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ==============================================================================