git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: git rebase -i onto HEAD~n

From
BABisani, Alok <alok.bisani@credit-suisse.com>
Date
Feb 3, 2009, 17:55 UTC
Message-ID
<C5E2CAEE4A87D24DAB5334F62A72D1F43ADCA2@ELON17P32001A.csfb.cs-group.com>
In-Reply-To
<20090203170457.GB6859@atjola.homenet>
Show 11 quoted lines
>On 2009.02.03 16:22:22 -0000, Bisani, Alok wrote:
>> >And in the editor:
>> >pick HEAD~2
>> >squash HEAD
>> 
>>     # Leave editor for ~/gittest/.git/rebase-merge/git-rebase-todo with
>>     squash 8df4c33 two
>>     # deleted line with discard
>>     squash 91f8267 three
>
>Notice the difference? You're trying to squash 8df4cee into nothing. And _if_ that would work, it would still squash 8df4c33 into the previous commit, which is not what you wanted anyway.
Yes, it is clear now. Thank you. And actually, the help page http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html states this clearly as well: 'If you want to fold two or more commits into one, replace the command "pick" with "squash" for the *second_and_subsequent* commit.'
However, I _did_ want to squash 8df4c33 (HEAD~2) etc, into HEAD~3 (the first commit). But unfortunately I cannot do $ git rebase -i  HEAD~4, as HEAD~3 is the first commit. Although, I understand that it will hardly be ever used in practise.
Is there a way to have git rebase --amend the --onto commit?

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 ==============================================================================

Previous: Björn SteinbrinkNext: Sitaram Chamarty
Message 5 of 6 in “git rebase -i onto HEAD~n”
  1. Bisani, AlokFeb 3, 2009
  2. Björn SteinbrinkFeb 3, 2009
  3. Bisani, AlokFeb 3, 2009
  4. Björn SteinbrinkFeb 3, 2009
  5. Bisani, AlokFeb 3, 2009
  6. Sitaram ChamartyFeb 3, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.