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
TKTorsten Krah <krah.tm@gmail.com>
Date
Jan 7, 2020, 15:28 UTC
Message-ID
<f0638fc0d09c213b661d2b244d3457f362daebe0.camel@gmail.com>
In-Reply-To
<234df85965f8a685be5e563fe795ed477f359d7c.camel@gmail.com>
Am Dienstag, den 07.01.2020, 14:43 +0100 schrieb Torsten Krah:
> Although restore --staged moved my unwanted files away from the
> staging
> area and "git status" told me that they are not "in" the commit the
> commit itself did still include them.
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.

What does work:
   git clone XX main
   cd main
   git fetch XX && git checkout FETCH_HEAD
   git checkout -b TEST
   git reset --soft HEAD~1
   git reset HEAD $FILES

git status now lists $FILES as unstaged and they are not included in the staging area.

   git commit

produces a commit where $FILES are not included and they are still in the working area, unstaged - like expected.

git status tells me this in the staging area part:
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)

I did that and its not working (for me) - looks at least like a bug or I am doing something wrong and I am just too dumb at the moment to see my failure.

Cheers
Torsten
PS: $FILES are files which are all "new" and first time added in the
commit I want to modify with restore.
PPS: The second problem with those staged deleted, unstageable,
uncomittable files still persists in my copy of those branch (I can't
reproduce that - still I have the repository in that state).
Previous: Torsten KrahNext: Jeff King
Message 3 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.