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

Re: tools for easily "uncommitting" parts of a patch I just commited?

From
Duy Nguyen <pclouds@gmail.com>
Date
Oct 23, 2016, 01:23 UTC
Message-ID
<CACsJy8Bz-DhE+CkJH+3zsrZJUQfGYDN072MKawJ6dx5begfnMw@mail.gmail.com>
In-Reply-To
<147712794056.12237.1478296296628149440@typhoon.fritz.box>
On Sat, Oct 22, 2016 at 4:19 PM, Lukas Fleischer <lfleischer@lfos.de> wrote:
Show 30 quoted lines
> On Thu, 20 Oct 2016 at 19:27:58, Jacob Keller wrote:
>> [...]
>> I still think we're misunderstanding. I want git commit to complain
>> *only* under the following circumstance:
>>
>> I run "git add -p" and put a partial change into the index in <file>.
>> There are still other parts which were not added to the index yet.
>> Thus, the index version of the file and the actual file differ.
>>
>> Then, I (accidentally) run "git commit <file>"
>> [...]
>
> This reminded me of something that bothered me for a while. It's not
> 100% on-topic but still quite related so I thought I'd bring it up.
>
> When working on a feature, I usually try to make atomic changes from the
> beginning and use `git commit -a` to commit them one after another. This
> works fine most of the time. Sometimes I notice only after making some
> changes that it might be better to split the working tree changes into
> several commits.
>
> In that case, I git-add the relevant hunks and then, unfortunately, I
> often run `git commit -a` instead of `git commit` (muscle memory bites
> me), so I need to do all the splitting work again.
>
> It's not much of an issue but would it be worthwhile to add an optional
> feature (configurable) that warns you when using --all with staged
> changes (which are not new files)? Are there others having the same
> issue? Do you think this should be implemented as part of an alias
> instead?

I hit the same problem sometimes, but in my case sometimes I accidentally do "git add" after "git add -p" and a configuration in "git commit -a" won't help me. I'd prefer we could undo changes in index instead. Something like reflog but for index.

-- 
Duy
Previous: Jacob KellerNext: Jeff King
Message 14 of 16 in “tools for easily "uncommitting" parts of a patch I just commited?”
  1. Jacob KellerOct 19, 2016
  2. Jeff KingOct 19, 2016
  3. Jacob KellerOct 19, 2016
  4. Jeff KingOct 20, 2016
  5. Jacob KellerOct 20, 2016
  6. Junio C HamanoOct 20, 2016
  7. Jacob KellerOct 20, 2016
  8. Junio C HamanoOct 20, 2016
  9. Jacob KellerOct 20, 2016
  10. Junio C HamanoOct 20, 2016
  11. Jacob KellerOct 20, 2016
  12. Lukas FleischerOct 22, 2016
  13. Jacob KellerOct 23, 2016
  14. Duy NguyenOct 23, 2016
  15. Jeff KingOct 23, 2016
  16. Duy NguyenOct 23, 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.