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

Re: git commit --amend safety check?

From
Peter Krefting <peter@softwolves.pp.se>
Date
Mar 11, 2015, 08:37 UTC
Message-ID
<alpine.DEB.2.00.1503110931100.26355@ds9.cixit.se>
In-Reply-To
<xmqq8uf46ru8.fsf@gitster.dls.corp.google.com>
Junio C Hamano:
> Having said that, disabling --amend and forcing to use --force or 
> something when it is clear that the user is attempting something 
> unusual is a good idea.  But I am not sure what the definition of 
> unusual should be.

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.

Of course, you should be able to do the amend commit, but then you would need to say something like "git commit --amend --force" to indicate that you really want to do that.

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).

-- 
\\// Peter - http://www.softwolves.pp.se/
Previous: Jeff KingNext: Junio C Hamano
Message 7 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.