19

I have a repository that is managed by tfs. However locally I would like to manage it via git and the push changes to tfs. Once I'm creating git repo over there VS2013 in team explorer shows this solution managed by git only. If I try to edit any file it complains that file is read only only I cannot save it in a previous version. So my question is there any way for Visual Studio 2013 to forget about git at all and manage it as tfs repository. I can manage git from command line. Or is there a way to make it to checkout files from tfs repo when I'm doing a changes?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
AlexanderM
  • 1,613
  • 4
  • 21
  • 35
  • 1
    If you're using TFS 2012 or newer, you can try using a local workspace (as opposed to server workspace), which leaves the files as writable by default. Then you shouldn't get complaints about files being RO. – Jimmy Nov 20 '13 at 20:15
  • It's easy with currently unpublished NoGit release, see http://stackoverflow.com/a/33789257/2284031 – Ben Wilde Nov 18 '15 at 20:01

5 Answers5

15

The solution outlined here works well for me: How can you disable Git integration in Visual Studio 2013 permanently?

Essentially:

  • Rename .git folder to _git, as @jessehouwing says
  • Create a text file called .git containing just the line "gitdir: /Path/To/_git"
  • Add _git to .gitignore

Visual Studio will now only use TFS and git works properly as well.

Community
  • 1
  • 1
Eric
  • 890
  • 1
  • 7
  • 9
  • quick note: the line in .git file can be just `gitdir: _git`, since you've just renamed it from the .git folder – Chin Feb 10 '15 at 15:10
  • I used this command in Windows (w/out quotes): "echo gitdir: _git >.git" -- and it did not work because of the space after _git -- "echo gitdir: _git>.git" did work. – J.Merrill Mar 31 '15 at 20:42
13

For your scenario Git-tf is probably a better solution, it will create a local git repo based on your TFVC source control folder. When you're done, you can push your changes from Git directly to TFVC from the commandline. Since you're already comfortable on the commandline, that might work out pretty well for you.

It's very hard to force Visual Studio to currently stay on Team Foundation Source Control when there is a git repo in the same folder.


As a horrible workaround, close your solution, rename the .git folder to _git and reload the solution. This should bring TFVC back, but if it doesn't, then rebind the solution to TFVC if using file->source control->advanced->Change Source Control. Then after checking in, close the solution again, rename _git back to .git and reload.


As Ed mentions in the comments, you can move your .git folder to another folder, like this:

 \MyProjects
    \GitRoot
     |  \.git
     \MySolution
      \MyFirstProject
      \MySecondProject

This allows Visual Studio to use the TFVC bindings and you can tell the git commandline that the .git directory is elsewhere using the git --git-dir=\MyProjects\GitRoot\.git command argument.

You can set an environment variable named GIT_DIR to fix that in one go, as @hlovdal mentions.


And there is another trick that @Eric mentions which creates a text file names .git that has the following in it:

gitdir: _git

Rename .git folder to _git, then make sure you add _git to .gitignore

Tip: to create a file that starts with a . from Windows Explorer you can use the New/Text Document option:

enter image description here

Then name the file .git. (make sure the Show file Extensions option is ticked):

enter image description here

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • Indeed. You could also create the `.git` directory in another location and use `git --git-dir=...` to point to the proper location. – Edward Thomson Nov 20 '13 at 20:00
  • 1
    Instead of having to add `--git-dir` on the command line you can set environmental variable `GIT_DIR` (as well as GIT_WORK_TREE). – hlovdal May 11 '15 at 10:28
12

I suggest theses steps :

  1. Go to TOOLS Tab in Visual Studio
  2. Select Options items
  3. On the left, select Source Control
  4. In the Plugin Selection Item, Enter None in the dropdownlist associated enter image description here
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51
  • 3
    This disables tfs integration which i don't want to loose. I would like to force TFS instead of git. But forcing in that options TFS getting my solution unloaded. Once I load it back I'm greeted with git source control again. Any attempt to switch to tfs unloads my solution and here we go again. – AlexanderM Nov 20 '13 at 16:55
  • because you are not connected to team project, select TEAM Tab, enter url team project and your credentials. you can pass also with Team Explorer – Aghilas Yakoub Nov 20 '13 at 16:58
  • 4
    Changing back unloads the solution and when you load the solution it goes back to git. – jessehouwing Nov 20 '13 at 17:13
  • Any solution for this so far? – GameScripting Jan 14 '14 at 15:30
  • 1
    This was happening to me when I had a .git folder in my home directory C:\Users\\[user name]\.git . Deleting the git folder resolved the issue. – adotout Sep 17 '14 at 01:35
0

You can remove the git support from Visual Studio 2013 using some registry hacks. It's of course a bit risky, but I've yet to have any problems after removing git support using this method:

http://blog.markrendle.net/disable-the-git-source-control-add-in-in-vs2013-permanently/

It boils down to just removing everyhing associated with the GUID {11B8E6D7-C08B-4385-B321-321078CDD1F8}

Anders Abel
  • 67,989
  • 17
  • 150
  • 217
Earlz
  • 62,085
  • 98
  • 303
  • 499
  • this doesn't work - see updated post (the plug-in also doesn't work as of VS 2013 update 3): http://blog.markrendle.net/disable-the-git-source-control-add-in-in-vs2013-permanently/ – Jordan Oct 16 '14 at 14:24
  • @Martin yea, nothing works in my experience. The good news though is that most of my git performance issues went away after update 3 with uninstalling resharper – Earlz Oct 16 '14 at 14:38
  • I'm just keeping git projects in a separate workspace now - my problem was that I needed to use TFS for source control, but it kept on picking up on a .git thanks to a code sample I downloaded during a Microsoft training event... the Microsoft Git Provider is pure evil.. It's extremely aggressive and can't be deleted... I really hope Microsoft comes up with a fix to allow us to disable it – Jordan Oct 16 '14 at 14:48
0

Bad Solution: Close your solution, rename the .git folder to _git and reload the solution worked for me. Thanks jessehouwing.

Harinath
  • 3,791
  • 2
  • 16
  • 34