Error creating new Git project in Visual Studio 2013

I am using Visual Studio 2013 with the MS Git plugin. I am trying to add an existing project to the original control on my machine. A project is an empty project with one file. The way to solve the project C:\_Projects\HelloGitWorld\HelloGitWorld.csproj - according to the Git settings, I created the default repo location, but it does not seem to store the repo (I tried this for other projects, and also created the repo in the same location as the solution).

So, I basically right-clicked on the solution and selected "add to source control". It is simple enough, and as soon as I do this, I get:

 The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. 

I understand that you can do this through Git bash, and I will eventually switch to this, but for now I just want to add a local repo for this. Why won't it let me? Where is it trying to create too long a path?

+6
source share
2 answers

Although you are creating a project under your "default repository location", this does not mean that a Git repository will be created for you. You need to create (or clone) the Git repository before creating a project / solution or using the "Add to Source" option to ensure that a new repo is created for you.

"The default location for the repo is not a Git repository, and the solution folder is not (by default) the Git repository.

The real purpose of VS "default Git repo location" is that the VS-tool system can localize localized locations of localized repositories. It will search for the folder you specify and (I suppose) any subfolders. Any folders that are recognized as the roots of the Git repository will be displayed in the Repositions list on the Connection page in Visual Studio UI.

If you want to use the command line this page on git -scm.com is a small snippet that shows how to create a folder and initialize it as a Git repository (locally). Here is an example showing how to initialize your solutions folder as a new local Git repository from powershell (with msysgit ):

 set-alias git "C:\Program Files (x86)\Git\bin\git.exe" cd "C:\_Projects\HelloGitWorld\" git init git add . git status 

From there, you can launch a visual studio, download a project / solution, and see that Git integration now works as intended. The same set of commands can be executed from the CMD shell, but you may have to specify the full path to git or just use Git bash (which can be tedious for you if you are not used to using unix shells.)

If you do not want to use the command line tool, you can use Visual Studio Tools for Git and select "New .." from the "Connect to Team Projects" panel (thanks to Edward Thomson for pointing this out) or use a third-party tool like TortoiseGit . This will make it easier to create a Git repository without requiring you to understand how Git works and how to work with the command line. For most scenarios, you can completely rely on Visual Studio Tools for Git. No need for anything else.

I use visualstudio.com and github.com to host projects, as well as the bare (private) repositories on the secure SAN in my house (because, after all, you cannot trust anyone anywhere with your private work. I'm not care what people say.) You can find this article on saintsjd.com useful in resolving the issue of bare repo - this is what you really need, and fooobar.com/questions/30657 / ... to see how to create it by yourself.

Let me know if I can clarify anything or if you need examples.

+4
source

You mentioned the MS Git plugin - why do you use it when VS2013 supports Git by default? I use the standard VS2013 Git + Git integration for Windows to synchronize my solution with Bitbucket and it works great. I also saw this weird default repository location setting, but all Git repositories are actually located inside the .git folder in my solution when I use the “Add to source control ...” solution context command (at this point you can create your Git repo from scratch). And in fact .git folder + .gitattributes and .gitignore are your local Git repo, which you may or may not synchronize with an external hosted Git repository such as Bitbucket and Github. If you want to remove the Git binding for your solution, just delete the specified folder and files.

As for the long path error, you can check your actual solution path in the solution explorer (select the root element of Solution and press F4).

Here are some links to help you get started:

It is worth mentioning here that if you are looking for free private Git hosting, then you may need Bitbucket (private repositories are free for groups of up to 5 people). If a small fee for private repositories does not distract you, you can go with Github , which is the largest Git repository hoster. Disclaimer: I am not affiliated with Bitbucket and Github in any way, this is simply the result of my personal investigation.

I also have to admit that I'm not a fan of command line tools, so my solution is good if you don't like it either.

0
source

All Articles