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

Re: how to squash two commits into only one

From
LLLynn Lin <lynn.xin.lin@gmail.com>
Date
Mar 29, 2011, 08:24 UTC
Message-ID
<AANLkTin-0cBa293CQSf4kwMUG=w2j5zkSz1oBDhNqaNe@mail.gmail.com>
In-Reply-To
<AANLkTi=5e4WUuZHcEJD50yJTw2eyYN_dN1S_7z62qy88@mail.gmail.com>
On Tue, Mar 29, 2011 at 2:15 PM, Tor Arntsen <tor@spacetec.no> wrote:
Show 29 quoted lines
> On Tue, Mar 29, 2011 at 07:42, Lynn Lin <lynn.xin.lin@gmail.com> wrote:
>> All,
>>   I have only have two commits in repo,then I want to squash these
>> two commit into one through git rebase -i .However it fails
>>
>> $ git rebase -i HEAD^1
>> it only show up one commit so can't squash (can't squash without a
>> previous commit)
>
> To squash commits with rebase -i:
> git log
> (identify the commit you wish to squash to)
> git rebase -i <the commit _before_ the one you want to squash to)
>
> e.g.
> git log
> 1
> 2
> 3
> 4
> ..
> you want to squash 2 into 3: Use git rebase -i 4
> (4 is really a hash of course).
>
> HEAD^some-value is OK sometimes but when I want to fix stuff down in
> the commit chain somewhere I find it simpler to use the hashes - just
> mark and paste.
> Anyway the real point is that with rebase -i you must specify the last
> commit _before_ the range you want to work with.

Thanks .However my case is like: git log 1 2

I want to squash 1 to 2,what's the commit I should specify with rebase -i
> -Tor
>
Previous: Tor ArntsenNext: Tor Arntsen
Message 3 of 14 in “how to squash two commits into only one”
  1. Lynn LinMar 29, 2011
  2. Tor ArntsenMar 29, 2011
  3. Lynn LinMar 29, 2011
  4. Tor ArntsenMar 29, 2011
  5. Alex RiesenMar 29, 2011
  6. Lynn LinMar 29, 2011
  7. Alex RiesenMar 29, 2011
  8. Joshua JuranMar 29, 2011
  9. Nguyen Thai Ngoc DuyMar 29, 2011
  10. Joshua JuranMar 29, 2011
  11. Will PalmerMar 29, 2011
  12. Junio C HamanoMar 29, 2011
  13. Dirk SüsserottMar 30, 2011
  14. Lynn LinMar 29, 2011

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.