0

I keep getting this error whenever I try to stage both (index.html) files at once.

I'm using VS Code and every time I make changes to the file it appears twice on the git source control tab. I have double-checked to make sure the containing folder only contains one file named index.html and I have also made sure no other similar file exists named in a different casing like (INDEX.html)

I'm only able to stage, commit and push one of the duplicate (index.html) files. The other one is stuck there, unable to even be staged. Please help.

Jdslk
  • 97
  • 3
  • 8
  • Please provide more details. How could one reproduce the problem you have from 0? Can you provide step-by-step instructions for that? – Lajos Arpad Jul 21 '21 at 10:13

1 Answers1

0

I glean from the question that you have a change you want and one that you do not want (the duplicate).

  1. Attempt to stash the change that you do want, so that you may use it after you've deleted the duplicate. This leaves you with just the change you'd like to get rid of.
  2. Sometimes, things get stuck at this point:
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working 
directory)

This can be resolved by forcing git to ignore the change you do not want. To do this run:

git ls-files -m | xargs -i git update-index --assume-unchanged "{}"

if on Windows. Credits for above command: Git: How to revert 2 files that are stubbornly stuck at "Changed but not committed"?

basecamp
  • 81
  • 1
  • 5