Re: how to squash two commits into only one
- From
- Joshua Juran <jjuran@gmail.com>
- Date
- Mar 29, 2011, 13:12 UTC
- Message-ID
- <04C85603-1737-42BC-A037-2C45D5315435@gmail.com>
- In-Reply-To
- <AANLkTinjbXzdfkxVRPPSXJj6Z0mMrikzdi2V8N5YAGR-@mail.gmail.com>
On Mar 29, 2011, at 5:49 AM, Nguyen Thai Ngoc Duy wrote:
Show 18 quoted lines
> 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. 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