Associate git with solution in VS2010 - visual-studio-2010

I noticed the TFS and Ankh (svn) plugins for VS2010 will annotate the .sln file with a GlobalSection that associates the solution with the corresponding source control provider. So when opening a solution will automatically tell VS to switch to that SCP. However the git plugin (combination of "git source control provider" and "git extensions for windows") does not do this.
So whenever I open a git solution, VS just uses whatever the last source control provider I was using the previous time I used VS for any solution, so I have to go through the Tools/Options menu and update it manually every time I open a git solution.
Is there a GlobalSection that will tell VS to use git, or some other way to allow VS2010 to detect that it's a git repo?

You can use this in .sln files
GlobalSection(GitScc) = preSolution
Git-Managed = True
Manager = Git Source Control Provider
EndGlobalSection
Cheers

Related

Visual studio keeps switching back to git source control provider

I don't want VS to fiddle with git, I use sourcetree for that, so I set the source control provider in the tools -> options -> source control to none.
As soon as you open a project that has git versioning on it the setting automatically switches back to git source control provider.
How to permanantly disable it?
I'm using visual studio 2013 update 5.
I found that I had this problem, even for projects that have never had anything to do with git. It started when I initialized a git repo in my C:\Users\<username> directory, and it went away wen I deleted the .git\ folder from that repo.
Just found an answer in a blog:
http://researchaholic.com/2015/02/02/remove-the-microsoft-gitprovider-from-visual-studio-2013/
To remove the git provider altogether one can delete the key
11b8e6d7-c08b-4385-b321-321078cdd1f8
from the registry via regedit:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\SourceControlProviders
note that you completely remove it, so only for people not interested in a CPU eating annoying ms-plugin.
I also found it does this, if you keep all of your source code in one base folder (in my case D:\Source). I have my TFS "root" mapped to D:\Source<project name>. As it turns out, I downloaded some sample Xamarin project from Microsoft using git & started in the D:\Source\ folder, which created the D:\Source.git folder. After creating this folder, it assumed anything that was a peer/sibling to that folder was a git repo.
Deleting this .git folder in my TFS path fixed it for me.

Visual Studio: How to create project from existing GitHub repository?

I came from Eclipse background and I am apparently missing something.
There is an existing GitHub project with JS code in it and I would like to start adding TypeScript nature to it, one type at a time.
I have followed this tutorial to clone project from GitHub to my "local git repository". Now the Team Explorer window displays it as local repository and I can commit changes etc but it's not a project and I don't know how to open it as a project (I want to open it as TypeScript project).
The workflow I was used to from Eclipse would simply be New -> Other -> SVN -> Checkout Projects from SVN that is automatically followed by New Project Wizard.
How do I clone existing JS project from GitHub and make it a TypeScrip project while keeping the existing folder structure?
EDIT: I am using Visual Studio Express and I am limited to the native Git extension.
What I typically do in this situation;
Clone repository using Git in Visual Studio; or use GitHub for Windows and Clone in Desktop from the Git project's web page. This will create a directory (repository) with the project files where you specify.
In visual studio, File->New->create a new project from existing code. From the wizard, select C# or C++ (whatever your choice it does not really matter)
The wizard requires a project file location: give the location of the Git folder that contains the project files (where you cloned the project's repository).
The Wizard requires a unique project name, for example you can use the name of the Git project with VisualStudio (or VS) appended to the end.
Git will now be in sync and you will be able to see all the git files. Making changes will check them out and allow you to push them to the project etc...
***** By default Git will want to check in the newly created .csproj file that Visual Studio creates to allow you to open the project in Visual Studio. You will just want to drag this into the excluded changes section because most likely the project in question will not be using Visual Studio.**
I solved this by opening the site as a website. File->Open->Website.
No Project Files/Solution files required. It just opens up the folder in the solution explorer.
To make it a typescript project, just add a tsconfig.json file to the directory.
Do you have any code in that repository yet that you want to open? I'm guessing not in which case you need to create a new VS project (just like you'd create a new Eclipse project and have it in your workspace)
Go to File, New..., Project... and pick the project type that you want. Give the project a name and set the location to be a folder INSIDE the folder that you cloned your Git repo to earlier (i.e. c:\mycode\mygitproject). Also give your solution a name. A "Solution" in Visual Studio is a wrapper for the projects inside it, kinda like the closest thing to a workspace or a working set in Eclipse but not quite the same thing.
Then Visual Studio should then be smart enough to pick up that this is in Git repo and allow you to commit locally as well as push/pull to GitHub etc.
Finally, while I work with the team that created the Visual Studio Tools for Git, I'd still highly recommend that you get hold of a command line should you want to do some more powerful stuff with Git other than simply committing code, push/pulling changes and branching or merging branches. If you are working against GitHub then you might also want to install GitHub for Windows which will bring some Git tools with it or you can install Git for Windows and also install Posh-Git separately. All of these things work together and give you the maximum power of Git but you can pick and choose the tool that works best for you. You'll probably find a workflow of Clone using GitHub for Windows, commit/push/pull/branch/merge in VS and then Posh-Git if you do more advanced stuff or want to hand-tweak settings.

Adding an existing folder to SVN outside of visual studio

I have created a repository online and I want to add an existing folder to it and make it version controlled. I am using TortoiseSVN.
When using Visual Studio I can just click "Add to Subversion" and it automatically adds the versioning to my project. When I click into the physical folder everything has icons next to it implying it's now versioned. I can then just commit it all either in or out of visual studio.
My problem is, I now have a folder that isn't part of a Visual Studio project that I want versioned. But I can't work out how to do it. If I click import I can import all the files but it doesn't add the versioning to the folder. I can then export it else where, but still I don't have the versioning.
What do I have to do to make my existing folder versioned without Visual Studio doing it?
You should read the SVNBook and TortoiseSVN manual. At least they'll help you to understand the concept behind Subversion and version-control in general.
When you svn import some folder to Subversion you can later get the working copy of this folder by doing a svn checkout operation in TortoiseSVN or a command-line client.
Whatever tool you are using in Visual Studio is using a subversion client under the hood - you can normally invoke this tool directly from the command line if wanted.
If you are not comfortable with that, you can download and install the free TortoiseSVN tool that integrates with the windows shell. Once installed, you can right click on the files/folders to add them to your repository outside of Visual Studio.
I have just worked out how to do this, so am answering my own question in case someone else is trying to do this:
Create the repository on the server,
svn import everything into it,
svn checkout what you just imported over the top of your existing folder.
Everything now will have ticks by it ready to commit!

How to switch from Ankhsvn plugin to VisualHG in Visual Studio 2010

When trying to switch my solution from using Ankhsvn to VisualHG (we've just migrated from SVN to Mercurial) I kept getting the following message:
"The active solution or project is controlled by a different source
control plug-in than the one you have selected. If you change the
source control plugin, the active solution or project will be closed.
Do you wish to continue?"
The solution would then close and when I re-opened it it would still be linked to Ankhsvn.
I tried deleting the source folder and grabbing a fresh clone out of Mercurial, but the problem kept coming back.
The solution required opening the .sln file in a text editor and manually removing the following block:
- GlobalSection(SubversionScc) = preSolution
- Svn-Managed = True
- Manager = AnkhSVN - Subversion Support for Visual Studio
- EndGlobalSection
After that I was good to go.
The above solution works but another way to do it without editing the sln is to open the project instead of the solution. Then change the setting at Tools->Options->Source Control->Plug-in Selection and change plug-in.
Make sure you save all - this should save the new Source control to the solution.
My solution is:
open solution normally with vs
disconnect all AnkhSvn project bindings
change source control plugin to VisualHG and save all

How to diff the current file when using GitExtensions

Is there a way to quickly do a diff the file currently being edited in
Visual Studio against its version in master? The best I've been able
to find is to do Git > Commit, and find the file in the list of
working dir changes.
Since you tagged your question with "git extensions" I'll go ahead and assume that you've installed Git Extensions. =)
Having installed Git Extensions you should in Visual Studio now have a new toolbar provided by Git Extensions.
What you also now have available are some new options in a series of context menus. Right click anywhere in a file you're working with in Visual Studio and select "Git: Diff". This will open your diff tool of choice showing you the changes in your working copy compared to the latest known commit in the branch your working in.
Use the git source control provider extension
http://visualstudiogallery.msdn.microsoft.com/63a7e40d-4d71-4fbb-a23b-d262124b8f4c/

Resources