Issue Type: Bug
Unable to do "git add" or any such command for an individual file, but works for adding or unstaging on all files. Works fine on command line though. The Git integration doesn't seem to be working for "git add" and other related commands in VSCode. Was working fine in previous versions of VSCode.
VS Code version: Code 1.41.1 (26076a4de974ead31f97692a0d32f90d735645c0, 2019-12-18T14:58:56.166Z)
OS version: Windows_NT x64 10.0.18363
(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
same with me. vscode 1.41.1, git 2.25.0, Windows 10 Pro 1903
it is an error with the absolute path to the file, if you have a spaces in it. Like here in "John Doe".
when hitting + in the git panel it executes:
git add -A -- c:\Users\John Doe\project\file.ts
and fails. same with executing it in ps.
but it works with relative path from ps:
git add -A -- .\file.ts
maybe there could be a setting to use relative paths?
ps: same with -
git reset -q HEAD -- c:\Users\John Doe\project\file.ts fails and
git reset -q HEAD -- .\file.ts works
Can you please provide a screen recording?
How does the error look like, when it happens?
OUTPUT > Git shows:
git.stage 1
git.stage.scmResources 1
> git add -A -- c:\Users\John Doe\project\file.ts
fatal: c:\Users\John Doe\project\file.ts: 'c:\Users\John Doe\project\file.ts' is outside repository
power shell shows:
PS c:\Users\John Doe\project> git add -A -- c:\Users\John Doe\project\file.ts
fatal: c:\Users\John: 'c:\Users\John' is outside repository
this works:
PS c:\Users\John Doe\project> git add -A -- .\file.ts
does this help?
Can you show me the full output of Git: Show Git Output?
I experience the same issue.
VSCode 1.14.1
git 2.25.0.windows.1
Windows 10 Enterprise 1803
Trying to stage or discard changes results in the error message
> git add -A -- C:\Repos\project\files.ts
fatal:C:\Repos\project\files.ts: 'C:\Repos\project\files.ts' is outside repository
Staging works, though.
Also, (I'm not sure if it's related) the functionality of the GitLens Extension is now broken as well, with it finding no file history for any given file in the repository.
Git output for staging changes:
git.stage 1
git.stage.scmResources 1
> git add -A -- C:\Repos\project\files.ts
fatal: C:\Repos\project\files.ts: 'C:\Repos\project\files.ts' is outside repository
Git output for discarding changes:
> git checkout -q -- C:\Repos\project\files.ts
fatal: C:\Repos\project\files.ts: 'C:\Repos\project\files.ts' is outside repository
full output of OUTPUT > Git is:
git.stage 1
git.stage.scmResources 1
> git add -A -- c:\Users\John Doe\project\file.ts
fatal: c:\Users\John Doe\project\file.ts: 'c:\Users\John Doe\project\file.ts' is outside repository
Can you show me the full output of Git: Show Git Output?
starting vscode
Looking for git in: C:\Program Files\Git\cmd\git.exe
Looking for git in: C:\Program Files (x86)\Git\cmd\git.exe
Looking for git in: C:\Program Files\Git\cmd\git.exe
Looking for git in: C:\Users\John Doe\AppData\Local\Programs\Git\cmd\git.exe
Looking for git in: C:\ProgramData\cmd\git.exe
Using git 2.25.0.windows.1 from C:\ProgramData\cmd\git.exe
> git rev-parse --show-toplevel
> git rev-parse --git-dir
Open repository: c:\Users\John Doe\Desktop\project
> git status -z -u
> git symbolic-ref --short HEAD
> git rev-parse master
> git show :server/index.ts
> git rev-parse --symbolic-full-name master@{u}
> git rev-list --left-right master...refs/remotes/origin/master
> git for-each-ref --format %(refname) %(objectname) --sort -committerdate
> git remote --verbose
> git config --get commit.template
> git check-ignore -v -z --stdin
hit +
git.stage 1
git.stage.scmResources 1
> git add -A -- c:\Users\John Doe\Desktop\project\server\index.ts
fatal: c:\Users\John Doe\Desktop\project\server\index.ts: 'c:\Users\John Doe\Desktop\project\server\index.ts' is outside repository
now this:
I renamed the folder of that project, cloned it again in to the old path, and copied all untracked files.
Oddly now it works perfectly.
The old project folder still refuses to work. so I think it may be corrupt.
so what ever was/is recloning worked for me.
thank you a lot!
same with me. vscode 1.41.1, git 2.25.0, Windows 10 Pro 1903
it is an error with the absolute path to the file, if you have a spaces in it. Like here in "John Doe".
when hitting + in the git panel it executes:
git add -A -- c:\Users\John Doe\project\file.ts
and fails. same with executing it in ps.but it works with relative path from ps:
git add -A -- .\file.tsmaybe there could be a setting to use relative paths?
ps: same with -
git reset -q HEAD -- c:\Users\John Doe\project\file.tsfails and
git reset -q HEAD -- .\file.tsworks
@dserke My path has no spaces or unnecessary characters. I still face that issue.
@dserke My path has no spaces or unnecessary characters. I still face that issue.
@aravindvnair99 did you tried to reclone it? this solved it for me. i don't think it is related to the spaces, as it works now with the same path. (including spaces)
Thanks @dserke !
I can confirm that deleting my project folder and recloning it made git work in VSCode again.
Also thanks to @joaomoreno for taking the time to look into this!
I'm having the same issue with git in VSCode (fatal: ... is oustide repository) when I try to perform any git action (discard, open changes with revision, etc) on any file within VSCode. I have no issues when I run the equivalent commands from the terminal. Re-cloning the repo doesn't sound like a proper fix if the issue is stemming from VSCode somehow.
@dserke My path has no spaces or unnecessary characters. I still face that issue.
@aravindvnair99 did you tried to reclone it? this solved it for me. i don't think it is related to the spaces, as it works now with the same path. (including spaces)
@dserke @The0frastus @Winston-Guess Yes, I just recloned 7 of my repositories and all of them are working fine now. But this is definitely a VS Code issue as it works perfectly fine on the command line. Also, I noticed that I face that issue when making any Git action (add, commit, etc) on individual files and not the entire set of changed files.
Can anyone who has seen the issue, yet has fixed it, repro the issue once again?
(edit: please ignore this comment - see related comment below)
I just checked what happened if I ran the commands in powershell and cmd and I get the same problem so this is not a VSCode issue. Should have checked this earlier 馃槄
(edit: found the same as @dserke's comment above - missed that)
I jumped the gun again 馃う鈥嶁檪 the commands fail in git bash as well but the problem seems to be that the commands are referencing the files using absolute paths and thus fails (not sure if absolute paths are normally meant to work)
The following absolute path command fails
git add c:\imqsbin\conf\clientconfs\ImqsMaintenanceManagement\1\forms\ir.processing_task.json
with the following error
fatal: c:\imqsbin\conf\clientconfs\ImqsMaintenanceManagement\1\forms\ir.processing_task.json:
'c:\imqsbin\conf\clientconfs\ImqsMaintenanceManagement\1\forms\ir.processing_task.json' is
outside repository
However, the equivalent relative path command works:
C:\imqsbin\conf> git add clientconfs\ImqsMaintenanceManagement\1\forms\ir.processing_task.json`
Can anyone who has seen the issue, yet has fixed it, repro the issue once again?
@joaomoreno I just managed to. I got the same error on a freshly created repository which I had cloned.
Are these paths remote paths? Or aliases?
With me, all are local files in c:\use on Windows 10 Pro, neither remote, not alias.
C:\>git --version
git version 2.25.0.windows.1
This error also happens in git from the command line, using absolute path.
git add pathspec examples all mention relative path (to the git top folder), not absolute (e.g. c:\abc).
This error also happens in git from the command line, using absolute path.
Interesting.
Does it reproduce with an older git version?
Yes, as seen below.
I believe there is something unstable in local git repository, since a new clone of the project is fine.
I am starting to feel this is more of a git issue, I will try to reproduce a full test case.
C:\use\bpm>git --version
git version 2.20.0.windows.1
C:\use\bpm>git status
On branch deps
Untracked files:
(use "git add <file>..." to include in what will be committed)
a.txt
nothing added to commit but untracked files present (use "git add" to track)
C:\use\bpm>git add c:\use\bpm\a.txt
fatal: c:\use\bpm\a.txt: 'c:\use\bpm\a.txt' is outside repository
@aravindvnair99: which git version you have, and which commands did you use to clone?
I also hope you can share the URL of the repository if it is public.
Merging with https://github.com/microsoft/vscode/issues/89373
@asashour @doudou @aravindvnair99 Do you have core.ignorecase = false in your git settings?
@asashour @doudou @aravindvnair99 Do you have
core.ignorecase = falsein your git settings?
@joaomoreno Yes, I have that set.
@aravindvnair99: which
gitversion you have, and which commands did you use to clone?I also hope you can share the URL of the repository if it is public.
@asashour I'm using git version 2.25.0.windows.1 and I face the issue with all of my repositories where I have core.ignorecase = false only with VSCode and nothing else.
I can confirm, it is due to the ignorecase = false with me
Thanks for confirming, working on a fix right now.
We fixed the error by moving the files outside of our OneDrive