gitextensions / gitextensions.vsix

Visual Studio extensions for Git Extensions
MIT License
16 stars 8 forks source link

Message box "The current directory is not a valid git repository" when using Git Extensions via Visual Studio Plugin #24

Closed jhollmannk closed 3 years ago

jhollmannk commented 7 years ago

If you try to open Git Extensions via the Visual Studio Plugin (e.g. to commit, view file history, etc.) you always get this error message if the current file is in a subdirectory of the git repository.

So if your git repository (with the solution) is in "m:\" and the current file is in "m:\io", Git Extensions are opened with "M:\io" as the current directory which leads to the error message.

You have to go up the directory tree until you find the ".git" folder to determine the repository root. This does not seem to happen.

Occurs in Visual Studio 2013 and Visual Studio 2015 with Git Extensions 2.49.

jhollmannk commented 7 years ago

This is related to gitextensions/gitextensions.vsix#6

In the case of clicking the Browse-Button, the current directory is given to Git Extensions. In this case there is no error message dialog box (the message is displayed in the view pane) but the git repositoty is still not found and instead you get the button to initialize a git repository in the subfolder.

I don't think this is what you want with "Browse".

I might add that the functionality in version 2.47 was as I described above (search for a git repository by going up the directory tree).

jhollmannk commented 7 years ago

This does not happen when I'm working on the Git Extensions repository itself. That's odd and I found the cause for this behavior:

We use SUBST under windows to create a build environment that's the same for every developer regardless of where the source code might actually be on the individual computers. That's why our source code (and therefore the git repository) is in the top level directory of a drive (in this case m:).

This does not work then, because GetDirectoryName (in PathUtils) explicitly returns an empty string when it reaches the top level of a drive. That results in the fact that FindGitWorkingDir cannot find a git repository on the top level of a drive.

And this worked for the Git Extensions repository because (luckily) that is in a subfolder.

paldrich01 commented 7 years ago

Hi, I ran into this issue today. Hope it's okay if I leave a comment based on my experience. I saw the error when I tried to commit, pull, push or stash, and the repository browser showed a different file path than the correct one. To fix it, I pulled down the repo clean, and in Git Extensions clicked Browse repository, then clicked the Initialize repository button. I had to setup branches again of course, but this did fix the issue for me (as a workaround). Hope this helps someone.

galsi commented 5 years ago

Any Update on this bug - i have same problem on latest version 3.1 Is there a workaround - https://github.com/gitextensions/gitextensions/issues/3457#issuecomment-284892333 - this one did not help

RussKie commented 5 years ago

You need to have a file opened that resides in a valid git repo The vsix just launches an instance of GE passing a path to the active file

galsi commented 5 years ago

Thanks working great now

GintasS commented 3 years ago

This seems to be fixed, as per the comments?