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

Commit includes rename which was not staged, nor actually performed

From
EBErwin Bonsma <erwin.bonsma@gmail.com>
Date
Apr 8, 2020, 19:28 UTC
Message-ID
<CAG5PFTvqnR-aeJ=+4W5A5WKqJ8Wq3JsD7J5QjwprE+Nws+=YBg@mail.gmail.com>
Hi,

I encountered a problem with git version 2.24.1 (Apple Git-126). When committing changes to a single file, the commit included a rename, which was not staged, nor actually carried out.

More specifically:
> git status
On branch unwanted-rename
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
modified:   it.xliff
Untracked files:
  (use "git add <file>..." to include in what will be committed)
Pending/it.xliff.todo
> git commit -m "Some fixes"
[unwanted-rename 98098ab] Some fixes
 2 files changed, 792 insertions(+), 826 deletions(-)
 rename de.xliff => Pending/it.xliff.todo (56%)
> git log --name-only HEAD~1..HEAD
commit 98098abe5bc9c10a644009e6d185fa967941caca (HEAD -> unwanted-rename)
Author: Erwin Bonsma <eriban@users.sourceforge.net>
Date:   Wed Apr 8 20:47:09 2020 +0200
    Some fixes

Pending/it.xliff.todo it.xliff

> ls de.*
de.xliff # The file is still present
> git status
On branch unwanted-rename
Untracked files:
  (use "git add <file>..." to include in what will be committed)
Pending/it.xliff.todo # The file is still untracked
> rm Pending/it.xliff.todo
> git checkout master
> git checkout unwanted-rename
Now let's inspect the resulting revision again.
> ls de.*

ls: de.xliff: No such file or directory # The file is now gone, as commit suggested

> ls Pending/it.xliff.*

Pending/it.xliff.todo # The untracked, removed file was indeed added to source control

The changes can be reproduced on the unwanted-rename branch available at https://git.code.sf.net/p/grandperspectiv/localization

The branch includes the wrong commit. To reproduce it:
> git reset --soft HEAD~1
> git restore --staged de.xliff
> git restore --staged Pending/it.xliff.todo
> git restore de.xliff
Now working copy is ready for replay.
> git status
On branch unwanted-rename
Your branch is behind 'origin/unwanted-rename' by 1 commit, and can be
fast-forwarded.
  (use "git pull" to update your local branch)
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
modified:   it.xliff
Untracked files:
  (use "git add <file>..." to include in what will be committed)
Pending/it.xliff.todo
> git commit -m "Some fixes"
[unwanted-rename 4d1368c] Some fixes
 2 files changed, 792 insertions(+), 826 deletions(-)
 rename de.xliff => Pending/it.xliff.todo (56%)

Cheers, Erwin

Next: Jeff King
Message 1 of 3 in “Commit includes rename which was not staged, nor actually performed”
  1. Erwin BonsmaApr 8, 2020
  2. Jeff KingApr 9, 2020
  3. Erwin BonsmaApr 10, 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.