Using Local Git and (Remote) TFS with Visual Studio 2013

I started working on some code locally and used Git (Git Gui and command-line) to manage it. Now I was asked to include the project in TFS "on the corporate". I can access TFS remotely using a VPN connection.

The code for VS is one solution with several projects. I successfully added a solution for TFS using VS, and he seemed to find all the projects and add his .csproj files and all the code to the TFS source code.

Later, when it is not connected to TFS (VPN disconnected), I made a simple change and transferred it to the local Git repository. I had nothing but disappointment trying (to connect to the VPN and) trying to commit the change to TFS.

I am running Visual Studio. On the tab "Team Explorer - Home" there is "Home | Offline". I check Tools / Options / Source Control and TFS is the current version control provider.

I click the plug icon in the Team Explorer toolbar; it remembers the connection and now shows "Connect | Offline"; Below is a line with the link "Select project projects ..." and two sections with triangular triangles next to each other. One has a TFS server name (followed by (1)); under this name (only) "team project", where it is stored in TFS. In another section there is "Local Git Repositories (1)" and the name of the solution is displayed with the path to the solution directory next to it. The title of the "Team Explorer - Connect" tab. I double-click the name of the team project, and the title of the tab changes to "Team Explorer - Home" and the screen displays "Home | {teamProjName}" and two sections. One of them has a “Project” with a “Web Portal” and the usual sections “Pending Changes”, “Source Control Unit”, etc. Below; and another "Solutions" section, which has the line "Workspace: {workspaceName} | New ... |" Open ... "; below this is the only solution file. I double-click the name of the solution, and now" Home | solutionName (Local) ", in the" Solutions "section there is now" Branch: master "(Git certificate), and Tools / Options / Source Control says that it has been changed to the Microsoft Git provider. If I return it back to TFS, says : "Home | Offline, "and I have to click the plug icon again, and I will go back to where I started, except that it says:" Connect | {solutionName} (Local) "

Opening a solution at first does not help; when I connect to TFS, the solution closes. Closing and opening VS simply begins with the fact that “VS knows about TFS, but you are offline” and opening a solution with active TFS allows you to switch to the Git provider in (local) mode.

I am very close to executing registry hackers to disable Microsoft Git Provider - I did my Git work using Git Gui and the command line; VS is not involved.

I've gone crazy? I would think that “developing locally using Git, connecting to TFS to synchronize with others” is the main use case for VS.

Any help would be greatly appreciated. Thanks.

+6
source share
3 answers

Visual Studio only sees git repositories if the .git folder is used as the repository for the git repository. So, we can fake VS using a different folder for the git repository.

  • Rename the current .git folder to _git ( .git dir may be hidden)
  • Create a text file in the same folder with the name .git containing only the line gitdir: _git (make the file through the command line: echo gitdir: _git>.git )
  • Add _git to your .gitignore file

Now when you start VS, it will not see the git repository and will use TFS instead.

+5
source

If the server is configured for TFVC and you have a local Git repository, then you cannot just push from local to tfs. You have two options. You can:

1) You can create a new team project configured for Git and click as usual.

2) you can use TF-Git to switch from the local Git repository to the TFVC server: http://www.microsoft.com/en-gb/download/details.aspx?id=30474

+3
source

I switched to using mercurial for my local repository. There is no VS integration in this (external commit required), but also no problems with VS.

0
source

Source: https://habr.com/ru/post/981565/


All Articles