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

Why does "git reset --hard" fail on file/folder conflicts?

From
Christian Halstrick <christian.halstrick@gmail.com>
Date
Oct 13, 2015, 06:36 UTC
Message-ID
<CAENte7i8jv5ET7v15HS-4bqbaGpdNkHFyX7upMHAmc0ykd1Mjw@mail.gmail.com>
Hi,

git doesn't want to do a git reset hard when for a certain path the index contains a tree, worktree contains a file and the commit to reset to contains nothing. Is it a bug or is it intended? I would expect git to simply delete that path from index and worktree.

> git init
Initialized empty Git repository in /tmp/y/.git/
> touch a
> git add a
> git commit -m addA
[master (root-commit) fa08136] addA
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a
Show 6 quoted lines
> mkdir d
> touch d/f
> git add d/f
> rm -fr d
> touch d
> git reset --hard HEAD

warning: unable to unlink d/f: Not a directory HEAD is now at fa08136 addA

Ciao
  Chris
Message 1 of 1 in “Why does "git reset --hard" fail on file/folder conflicts?”
  1. Christian HalstrickOct 13, 2015

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.