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

Re: amend warnings with no changes staged

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 6, 2019, 02:01 UTC
Message-ID
<20190806020132.GB61803@google.com>
In-Reply-To
<CAOY1tUVpeUftgHNuZg-2fMD9D+Qz08hfvRvQDe1f8+MV2xYv2w@mail.gmail.com>

(administrivia: please don't top-post) Lukas Gross wrote:

Show 6 quoted lines
> I had intended to stage commits but forgot to do so. Git responded
> with a normal commit creation message, so I pushed to the remote to
> begin a CI build. When the build failed for the same reason, I
> realized I had forgotten to stage the changes. An additional line in
> the response to the effect of “Warning: did you mean to amend with no
> changes?” would be very helpful to shorten this feedback loop.

Ah, I see. You passed --no-edit so you didn't see the usual --dry-run style output that "git commit" shows. You forgot to run "git add" before amending, and this is what you'd like commit to assist you with.

That said, this is sometimes an operation people perform intentionally.

Ideas:
* Can the documentation do a better job of steering people away
  from --no-edit?  The hints shown when "git commit --amend" (and
  --no-amend, for that matter) open a text editor tend to be very
  helpful for understanding what is going to happen.  If any
  documentation is leading people to forgo that tool, we should fix
  it.
* Should "git commit --no-edit" say a little more about what it did,
  since it knows that the user didn't get to see the text editor?
* Should we have a special option (e.g. "git commit --amend
  --refresh") for a no-op amend?  That ways, when a user doesn't pass
  that option, it would be more clear that it is a mistake, allowing
  a warning or even an error.

Of these three, the first seems most compelling to me. Others may have other ideas.

Thoughts?

Thanks, Jonathan

Previous: Lukas GrossNext: Jonathan Nieder
Message 4 of 13 in “amend warnings with no changes staged”
  1. Lukas GrossAug 6, 2019
  2. Jonathan NiederAug 6, 2019
  3. Lukas GrossAug 6, 2019
  4. Jonathan NiederAug 6, 2019
  5. Jonathan NiederAug 6, 2019
  6. Junio C HamanoAug 6, 2019
  7. Jonathan NiederAug 6, 2019
  8. Junio C HamanoAug 6, 2019
  9. Junio C HamanoAug 6, 2019
  10. Phillip WoodAug 6, 2019
  11. Jeff KingAug 6, 2019
  12. Junio C HamanoAug 6, 2019
  13. Jeff KingAug 8, 2019

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.