In VS Code, given a file, managed by git, which has been edited. I can select the file from the Source Control sidebar and see the diff highlighted. When I right-click on a change and select "Stage selected ranges" I get a pop-up with the error:
Git: cannot open git:~/repo_folder/path/to/file/.../CloudNgfw.ts?
%7B%22path%22%3A%22<URL-ENCODED-PATH-TO>%2FCloudNgfw.ts%22%2C%22ref%22%3A%22~%22%7D.
Detail: Unable to read file 'git:~/repo_folder/path/to/file/.../CloudNgfw.ts?
{"path":"~/repo_folder/path/to/file/.../CloudNgfw.ts","ref":"~"}'
(Error: Unable to resolve nonexistent file 'git:~/repo_folder/path/to/file/.../CloudNgfw.ts?
{"path":"~/repo_folder/path/to/file/.../CloudNgfw.ts","ref":"~"}')
I've found related-sounding SO answers which suggest git mv <Pascal-case> <correct case>
but this returned fatal: not under version control
and did not correct the issue.
I also tried preceding with a git mv <correct case> <Pascal-case>
- both commands executed without error, but the issue remains.
I'm using Cursor: 1.2.4 (Universal); VS Code Version: 1.99.3
I've also seen the same behaviour/error in vanilla VS Code upto/including today on Version: 1.99.3 but I've also seen the same thing today/in the past in vanilla VSCode Version: 1.101.1 (Universal)
Per https://stackoverflow.com/a/18000286/10761353 (and comments on the question), the suggested steps (peppered with git status
) was able to resolve the issue for VS Code 🥳
As for Cursor, the issue remains when using the rt-click menu... but using the grey Stage Block
button works as expected...? 🤕
While annoying, I hope my muscle-memory won't take too long to re-train!
The full sequence of commands was:
$ git status
On branch my_branch
Your branch is up to date with 'origin/my_branch'.
nothing to commit, working tree clean
$ mv CloudNGFW.ts /tmp
$ git status
On branch my_branch
Your branch is up to date with 'origin/my_branch'.
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)
deleted: CloudNGFW.ts
no changes added to commit (use "git add" and/or "git commit -a")
$ git rm CloudNGFW.ts
rm 'path/to/CloudNGFW.ts'
$ git status
On branch my_branch
Your branch is up to date with 'origin/my_branch'.
Changes to be committed:
(use "git restore --staged \<file\>..." to unstage)
deleted: CloudNGFW.ts
$ git commit -m 'deleting file'
\[my_branch 5913d58a\] deleting file
1 file changed, 203 deletions(-)
delete mode 100644 path/to/CloudNGFW.ts
$ git status
On branch my_branch
Your branch is ahead of 'origin/my_branch' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
$ git push
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 8 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 726 bytes | 726.00 KiB/s, done.
Total 6 (delta 5), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To github.com:nestoca/infra.git
ffc97718..5913d58a my_branch -\> my_branch
$ git status
On branch my_branch
Your branch is up to date with 'origin/my_branch'.
nothing to commit, working tree clean
$ mv /tmp/CloudNGFW.ts .
$ git status
On branch my_branch
Your branch is up to date with 'origin/my_branch'.
Untracked files:
(use "git add \<file\>..." to include in what will be committed)
CloudNGFW.ts
nothing added to commit but untracked files present (use "git add" to track)
$ git add CloudNGFW.ts
$ git status
On branch my_branch
Your branch is up to date with 'origin/my_branch'.
Changes to be committed:
(use "git restore --staged \<file\>..." to unstage)
new file: CloudNGFW.ts
$ git commit -m 'adding file'
\[my_branch a3877752\] adding file
1 file changed, 203 insertions(+)
create mode 100644 path/to/CloudNGFW.ts
$ git status
On branch my_branch
Your branch is ahead of 'origin/my_branch' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
$ git push
Enumerating objects: 12, done.
Counting objects: 100% (12/12), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 3.09 KiB | 1.54 MiB/s, done.
Total 7 (delta 5), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To github.com:nestoca/infra.git
5913d58a..a3877752 my_branch -\> my_branch
$ git status
On branch my_branch
Your branch is up to date with 'origin/my_branch'.
nothing to commit, working tree clean