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

git commit --amend safety check?

From
Shawn Pearce <spearce@spearce.org>
Date
Mar 11, 2015, 04:31 UTC
Message-ID
<CAJo=hJuwdOzNZSVBRAPDz97Gdoi6JWvYxE0ufY+Hd9K8jjCqfA@mail.gmail.com>

We keep seeing reports of Gerrit Code Review users who incorrectly do something like:

  git clone URL foo
  cd foo
  git commit --amend -m "My first change!" -a
  git push URL HEAD:refs/for/master

Step #3 is where they get into trouble. They just amended the published tip commit and pushed it back to the server. That is... lets just say not good.

Hg is known to be more user friendly. One way its user friendly is it by default refuses to let you amend a change set that the client has reasonable assertion to believe was already published through a remote repository.

For Git that would mean `commit --amend` refusing to amend (by default) if the commit is reachable from a refs/remotes/... tracking branch.

Thoughts?
Next: Junio C Hamano
Message 1 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.