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

[feature request] Warn about or prevent --amend commits that don't change anything

From
BBergi <a.d.bergi@web.de>
Date
Jul 13, 2016, 18:56 UTC
Message-ID
<d2c3365d-6da9-dd58-ae7d-4a2020c6b513@web.de>
Hello,

when nothing is staged in the index then `git commit` warns about this fact with either "nothing to commit, working directory clean" or "no changes added to commit". However, `git commit --amend --no-edit` will happily record a new commit that differs in nothing than its commit date from the original.

This is unexpected and can lead to mistakes. Without running `git status`, the user will not notice that his unstaged changes were not commited, as everything behaves as expected otherwise (the success output from `commit`, the new commit id in the log, `push` requiring the force option, etc).

I understand that `--amend` is (can be) used for editing commit messages, authors, authoring dates etc. I would however like to see any `--amend` command that results in no changes to the tree, the commit message and the authoring metadata reject the commit with an appropriate warning similar to the one that a plain `git commit` would present. It should be overrideable by the `--allow-emtpy` parameter as well.

If this change detection is somehow unfeasible, I would at least like the `git commit --amend --no-edit` command (with no other flags) to check the tree in the same way as `git commit` does, as the intention of `--no-edit` is even more clear and running the command is more obviously a mistake/lapse.

Kind regards,
  Bergi
Next: Junio C Hamano
Message 1 of 3 in “[feature request] Warn about or prevent --amend commits that don't change anything”
  1. BergiJul 13, 2016
  2. Junio C HamanoJul 13, 2016
  3. BergiJul 13, 2016

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.