threads / discuss / 40547

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

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

## tl;dr

One message between Oct 13, 2015 and Oct 13, 2015.

replies: 0people: 1as markdown or json

Christian Halstrick· Oct 13, 2015, 06:36 UTC · lore
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

← back to recent threads