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

Re: git commit --amend safety check?

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 11, 2015, 17:56 UTC
Message-ID
<xmqq1tkv770b.fsf@gitster.dls.corp.google.com>
In-Reply-To
<alpine.DEB.2.00.1503110931100.26355@ds9.cixit.se>
Peter Krefting <peter@softwolves.pp.se> writes:
Show 5 quoted lines
> For commit --amend, I would say it would refuse to amend if the commit
> you are trying to amend
>
>  1. was not authored by yourself (and --reset-author was not given), or
>  2. is reachable (or is the tip?) from an upstream branch.

I agree that 2. is a safe check without too much risk to trigger a false positive (and the tip of origin/master is reachable from origin/master, so we do not have to single out "is the tip").

On the other hand, 1. may be good in training wheel mode, but once you start allowing amends and rebases, I do not see why it should be considered possibly bad as long as check 2. says it is OK to rewrite.

> At least (1) would have saved myself from mistakes that take time and
> effort to clean up (I have used Git for eight years or so already, and
> I *still* do that kind of mistake every now and then).

Isn't your friend reflog helping you to clean things up? The difference between the state before you started amending and the current state is what you did since then, so...?

Previous: Peter Krefting
Message 8 of 8 in “git commit --amend safety check?”
  1. Shawn PearceMar 11, 2015
  2. Junio C HamanoMar 11, 2015
  3. Shawn PearceMar 11, 2015
  4. Junio C HamanoMar 11, 2015
  5. Mike HommeyMar 11, 2015
  6. Jeff KingMar 11, 2015
  7. Peter KreftingMar 11, 2015
  8. Junio C HamanoMar 11, 2015

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.