VSCode: git fatal error: file is outside directory

Viewed 11784

I have been using VScode for a long time, and I have used the git functionality a lot. But it has suddenly started failing. Every time I try to add a file, a single file, it says there is an error:

git add -A -- ""repository folder""/README.md

fatal: ""repository folder""/README.md' is outside repository

I have checked the settings and there is nothing weird and also, when I add all files at once instead of just one at a time, it works well. If I add the files with the terminal's commands, it works too.

9 Answers

I have got this problem after installing May 2020 VSCode update (v1.46).

After comparing git commands of the old and the new VSCode it appeared that updated VSCode uses low case drive letter in the path for the git command, but the old one used upper case letter. The ignorecase git option that should solve those problem was already set to true.

Updating git to version 2.27 solved the problem.

What fixed it for me was:

Being a Windows and VScode user, I fixed this by updating GIT. You do that by going to https://gitforwindows.org/ and installing.

my vs code recently got updated to May 2020 release. Just after this the above git issue starting happening. So i rollback version of my vs code to April 2020 release and now again git extension works

Looks like the root cause mentioned in someone else's answer is correct:

I have got this problem after installing May 2020 VSCode update (v1.46).

After comparing git commands of the old and the new VSCode it appeared that updated VSCode uses low case drive letter in the path for the git command, but the old one used upper case letter.

I can see the git error complaining about e:\... while Windows shows E:\....

Adding ignorecase=true didn't do it for me. Instead, I ran git version (which reported 2.9.x). The latest git as of writing was 2.27.y. Upgrading git solved it for me.

I had to change my git config to get this working in my vs code. From git version 1.6.1.9 for windows, "ignorecase=true' in config is set by default. If you did not previously configure this in your repos you can change it to false by doing the following via your terminal in the directory with .git folder in:

git config --local -e

Under the core options, set ignorecase to false using the text editor

ignorecase=false

Hope it helps

To users who use language other than English, this could help solving the problem.

git config --global core.precomposeunicode false

Problem is you're trying to add something, not in the root directory which includes .git directory and sub-dirs. The file you're trying to add is outside its scope.

Don't add the file as full path. Type git status on your branch and just add the file.

Just do the simple thing. For example:

git add README.md
git commit -m "Commit message"
git checkout master

You can merge or rebase depending on your choice.

If using: Mac OS 10 + VSCode Extension Git History 0.6.10.

Uninstalled restart VSCode reinstall Git History.

Working again.

Related