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

Re: Bug? git commit fileA tries to delete fileB and other oddities

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 15, 2019, 21:09 UTC
Message-ID
<nycvar.QRO.7.76.6.1912152209020.46@tvgsbejvaqbjf.bet>
In-Reply-To
<CA+PLxnUR2skor9CGfDKfEEm8XTmoHwM2cDf5Kpgt-ppo=4zhbQ@mail.gmail.com>
Hi Mikael,
On Sat, 14 Dec 2019, Mikael Simonsson wrote:
Show 15 quoted lines
> I have the following problems with a local repository:
>
> * git commit fileA tries to delete fileX (fileX still exists).
>
> * git restore --staged fileX doesn't work, the file remains staged.
>
> * A commit from a few days back deleted 2 random files that I haven't
> touched or staged in months and pulled in staged changes I didn't ask
> for.
>
> git version: 2.24.0 and 2.24.1 (OS: FreeBSD 12)
>
> How can this happen? The repository has a local remote (on the same
> filesystem) that is pushed to only. I tarred the project and copied it
> to a Mac with git 2.23.0 and the problem persists.

It would be good if you could come up with a minimal list of commands to recreate that problem. That way, we can turn it into a regression test and fix the problem.

Ciao, Johannes

Show 67 quoted lines
>
> For example (I've only changed the filenames):
>
> % git status
> On branch master
> Your branch is up to date with 'origin/master'.
>
> Changes to be committed:
>   (use "git restore --staged <file>..." to unstage)
>         modified:   fileA
>         modified:   fileB
>         modified:   fileC
>
> Changes not staged for commit:
>   (use "git add/rm <file>..." to update what will be committed)
>   (use "git restore <file>..." to discard changes in working directory)
>         ...
>
>
> % git commit fileA
>
> # Please enter the commit message for your changes. Lines starting
> # with '#' will be ignored, and an empty message aborts the commit.
> #
> # On branch master
> # Your branch is up to date with 'origin/master'.
> #
> # Changes to be committed:
> #       deleted:    fileX
> #       modified:   fileA
> #
> # Changes not staged for commit:
>
>
> % git stash
> Saved working directory and index state WIP on master: 488e7081 ...
>
>
> % git status
> On branch master
> Your branch is up to date with 'origin/master'.
>
> Changes to be committed:
>   (use "git restore --staged <file>..." to unstage)
>         deleted:    fileX
>
> Untracked files:
>
>
> % git restore --staged fileX
>
>
> % git status
> On branch master
> Your branch is up to date with 'origin/master'.
>
> Changes to be committed:
>   (use "git restore --staged <file>..." to unstage)
>         deleted:    fileX
>
> Untracked files:
>   (use "git add <file>..." to include in what will be committed)
>
>
> Thanks,
> Mikael
>
Previous: Mikael SimonssonNext: Mikael Simonsson
Message 2 of 5 in “Bug? git commit fileA tries to delete fileB and other oddities”
  1. Mikael SimonssonDec 14, 2019
  2. Johannes SchindelinDec 15, 2019
  3. Mikael SimonssonDec 16, 2019
  4. Jeff KingDec 17, 2019
  5. Mikael SimonssonDec 17, 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.