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

Re: Broken branch after git commit - tracked files in staging area can't be removed with restore --staged, or commit or stash

From
Jeff King <peff@peff.net>
Date
Jan 8, 2020, 09:11 UTC
Message-ID
<20200108091119.GB87523@coredump.intra.peff.net>
In-Reply-To
<f0638fc0d09c213b661d2b244d3457f362daebe0.camel@gmail.com>
On Tue, Jan 07, 2020 at 04:28:24PM +0100, Torsten Krah wrote:
Show 19 quoted lines
> I can reproduce that (locally) at least:
> 
> What does *not* work for me:
> 
>    git clone XX main
>    cd main
>    git fetch XX && git checkout FETCH_HEAD
>    git checkout -b TEST
>    git reset --soft HEAD~1
>    git restore --staged $FILES
> 
> git status now lists $FILES as unstaged and they are not included in
> the staging area.
> 
>    git commit
> 
> -> now $FILES are included in the commit (I would expect them not to be
> included - right?) and git status does list those still in the working
> area.

That step seems wrong, and I can't reproduce it here. If "git status" lists the files as unstaged, then "git commit" should not be committing them. Can you show us a more complete example that we can run ourselves (i.e., that does not rely on whatever is in "main", and what is in $FILES)? Barring that, can you show us the output of the commands, as well as "git show FETCH_HEAD FETCH_HEAD~1"?

-Peff
Previous: Torsten KrahNext: Torsten Krah
Message 4 of 13 in “Broken branch after git commit - tracked files in staging area can't be removed with restore --staged, or commit or stash”
  1. Torsten KrahJan 7, 2020
  2. Torsten KrahJan 7, 2020
  3. Torsten KrahJan 7, 2020
  4. Jeff KingJan 8, 2020
  5. Torsten KrahJan 8, 2020
  6. Torsten KrahJan 8, 2020
  7. Jeff KingJan 8, 2020
  8. restore: invalidate cache-tree when removing entries with --stagedJeff King, Jan 8, 2020
  9. Junio C HamanoJan 8, 2020
  10. Dennis KaarsemakerFeb 5, 2020
  11. Torsten KrahJan 8, 2020
  12. Jeff KingJan 9, 2020
  13. Torsten KrahJan 9, 2020

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.