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

Re: how to squash two commits into only one

From
Will Palmer <wmpalmer@gmail.com>
Date
Mar 29, 2011, 15:02 UTC
Message-ID
<1301410939.3012.12.camel@wpalmer.simply-domain>
In-Reply-To
<04C85603-1737-42BC-A037-2C45D5315435@gmail.com>
On Tue, 2011-03-29 at 06:12 -0700, Joshua Juran wrote:
Show 23 quoted lines
> On Mar 29, 2011, at 5:49 AM, Nguyen Thai Ngoc Duy wrote:
> 
> > On Tue, Mar 29, 2011 at 7:44 PM, Joshua Juran <jjuran@gmail.com>  
> > wrote:
> >> On Mar 29, 2011, at 3:58 AM, Alex Riesen wrote:
> >>
> >>> On Tue, Mar 29, 2011 at 12:10, Lynn Lin <lynn.xin.lin@gmail.com>  
> >>> wrote:
> >>>
> >>>> only have two commits
> >>>
> >>> Than yes, "git reset HEAD^; git commit --amend" seems the best  
> >>> solution.
> >>
> >> Actually, that should be:  `git reset --soft HEAD^; git commit -- 
> >> amend`.
> >
> > "git rebase --root" does not seem a bad idea though. I need to amend
> > initial commit a few times and end up using "git reset" without
> > --soft.
> 
> Or perhaps have `git commit --amend` issue a warning if doesn't  
> actually amend anything. ............................................

I like this idea. It's been in my notes for a while, but seems like it has a lot of potential to make existing scripts noisy for no reason. I do agree with the change, however.

The only constructive thing I'd add, as it's sitting in my notes right
next to "Warn if "git commit --amend" introduces no changes":
 - Add "git commit --reword", like --amend, but without the above
   warning

This would fit in with the existing names from "git rebase -i". --fixup (for "like --amend but do not ask for a message") seems like a sensible addition to those to, also following the lead of rebase -i, but --fixup=<commit> already means something different (though related), so it is probably a bad idea to overload --fixup with no =<commit>.

Show 16 quoted lines
> ........................ Sometimes you just want to change the commit  
> message, so you wouldn't want a warning in that case.  But other times  
> you're adding changes and updating the commit message at the same  
> time, so you'd want a warning if you forgot to git-add or use --soft.   
> A new --fix option to commit could work like --amend, but fail with an  
> error if no changes are staged.  Another option is for --amend to list  
> the staged changes in the edit buffer, or a warning when nothing has  
> changed.
> 
> Josh
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Joshua JuranNext: Junio C Hamano
Message 11 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.