How to enable git on existing TFS project? - tfs

Environment: Visual Studio 2017, TFS project set at visual studio online.
I am working on a community project. The source code is checked into TFS project using the free account provided by visual studio online.
I now need to enable git on this project such that others can use from other projects.
On TFS online, I see a way to create a new GIT-based project but I don't see any option to enable GIT on an existing TFS project. I remember to have used this option long time ago. Wondering where I can find this switch. Or, is there any easy way to migrate existing code to GIT. Regards.

You can use Import repository to import the Git repository from TFVC.
From the repo drop-down, select Import repository.
Select TFVC from the Source type dropdown
Type the path to the repository / branch / folder that you want to
import to the Git repository. For example,
$/0522TFVCScrum/BuildProcessTemplates
If you want to migrate history from the TFVC repository, click
Migrate history and select the number of days. You can migrate up to
180 days of history starting from the most recent changeset. A link
to the TFVC repository is added in the commit message of the 1st
changeset that is migrated to Git. This makes it easy to find older
history when needed.
Give a name to the new Git repository and click Import. Depending on
the size of the import, your Git repository would be ready in a few
minutes.
Refer to this article for details: Import repositories from TFVC to Git

Hover over the Code tab, click "Manage Repositories", then click the "New Repository" button.

Related

How to integrate TFS in WebStorm?

I'm using Git with WebStorm's version control already, but have to use TFS version control. After some research fond this plugin but there is no tutorial that aiming to configure that plugin.
Can anyone guide me?
You can opt for using git tfs, locally you can still use Git and all of the advantages you're used to. And then push from git to TFVC. You'll need to install Team Explorer or the Team Explorer Cross Platform Commandline Tools.
Or you can use the native plugin for, thelatest version of the TFS / Azure DevOps (Server) plugin can be found on the Jetbrains site. It requires TFS 2015 or newer. You can use the plugin you found for older versions of TFS.
A good explanation to get started can be found here. The part to configure TFVC is replicated below.
Visual Studio Team Services plugin and TFVC
Before starting with TFVC, we need an external tool. The tool in question is TF command line tool. It ships with the Microsoft Team Explorer Everywhere 2015 and you can download it here.
The file we are interested in is TEE-CLC-14.0.3.zip. Download it and unzip it in a folder of your choice. You should end up with something similar to this.
Now, open the command prompt, move into the folder where you have extracted the TF command line tool and run the following:
tf eula /accept
If command succeeded and you haven’t received any error, you are good to go.
Now back to IDEA. Open the settings panel.
and move to Version Control -> TFVC pane. In the select path to executable field, enter the exact path to the tf.cmd command file located in TF command line tool folder.
Once done, press the test button and you should see the following message
Confirm all of the open windows and get back to the IDEA welcome page. Now you are ready to choose Team Services TFVC (Preview) version control.
At this point, same as for Git, you will be prompted about the connection towards your TFS. The following dialog will be shown.
Move to the Team Foundation Server tab and specify the address of your TFS server, then click connect. You will now be prompted for the credentials and if everything is ok, you will be shown the list of available TFVC repositories.
You can now create a new workspace directly from IDEA and start working with your TFVC repositories.

How to clone a VSTS project/workspace locally?

We have a project/workspace setup in Visual Studio Team Services online. I would like to get a local backup of the workspace and project with all of its artifacts (attachments, Wiki notes and attachments, etc.).
Would a local version of TFS pointed to VSTS online clone the epics, features and stories locally? This is what I really need.
What is the process to accomplish this?
You can not clone the whole contents of a team project, but clone the source code from version control system (Git or TFVC) is possible.
If you are using Git as VCS, you can use below command to clone the VSTS git repo:
git clone <repo URL>
And you can also refer the document to clone a VSTS git repo via VS.
If you are using TFVC as VCS, you can map TFVC repo locally in VS. Detail steps you can refer Develop and share your code in TFVC using Visual Studio.
Seems you also want to migrate WIT from TFS to VSTS. You can refer these related posts: Migrate Workitems from local TFS into VSTS and Migrating Work Items from TFS 2017 to VSTS.
Besides, you can also refer the document Migrate data from TFS to VSTS.

remove git repository binding from visual studio 2015

Initially my project was mapped to a git repository.I Want to remove git mapping and bind it to tfs (vs2015).I removed .git folder and its related files from the solution(my local drive) and open the solution in vs2015 and change the source control option to tfs. when adding solution to the source control I'm getting the following error
"the current solution has projects that are located outside the solution folder.These projects will not be source controlled in git repository.To add all the projects to a single git repository please consider all projects under a single folder"
If I click on OK on this error dialog, it automatically adding git folder to the solution.
I removed source controler provider for GIT from the registry via regedit. Now when i try to add solution to the tfs I am getting the error "The project or solution you opened requires a source control plug-in that is unavailable at this time.
I've tried different ways nothing worked.
Create a new team project on the TFS web portal.
Start Visual Studio session. Select Tools->Options->Plug-in Selection and switch current source control plug-in to "Visual Studio Team Foundation Server".
From Visual Studio connect to the TFS and select the collection and the newly created team project. A local folder will be created for your new team project.
Copy all your sources in the local folder of the new team project.
Open the solution in the current session of Visual Studio. Add the solution node to the source control. Check in and your done.
You cannot change or mix TFVC with Git in the same project. You need to create a TFVC project, then check in the sources to the new project.
If you don't need to keep the source history, just pull down and check into the new version control as Mircea mentioned above.
If you want to keep the history, just try to migrate all history of main branch from local repo to a new TFVC team project with following steps:
Create an empty TFVC team project
Go to your local Repo folder, and use git-tf checkin --deep command
to checkin the local repo to a TFVC team project. By default, the
checkin command will create a single TFS changeset for the aggregate
of all changes made on the current branch in Git since the last
checkin to TFS. When used with the --deep option, a TFS changeset
will be created for each Git commit on the current branch since the
last checkin to TFS.

Using Xcode with TFS 2015 on-premises

Is there any way to check in code from Xcode to TFS 2015 on-premises installation? Even if TFS is just acting as a go between for Xcode and Git? The main thing we'd like to be able to do is for iOS code to be checked in to TFS with changesets recorded, and work items/bugs available.
Any suggestions? We are not looking to move to VS Team Services / VS Online.
you have 2 options.
The best option is to create a new TFS Team Project with Git for source control. Or you can add a Git repo so an existing Team Project. This is a standard Git repo, but hosted in TFS. It works just like any other hosted Git repo. Clone the repo and off you go.
If you cannot use Git inside TFS and you must use TFVC then you can use git-tf. This is effectively a bridge between a local git repo and a centralized TFS TFVC repo. This article should get you started
Both VSTS and TFS 2015 include full support for Git-based source control projects. You can follow MSDN article Share your code in Git using Xcode to push your project to TFS.
After pushing your project to TFS, you'll have full history and work item available:

Integrate crucible with tfs

I use TFS with Jira to managment my team tasks.
I want to integrate a Code Review tool at development process.
When i try to use crucible i reveal that it not support TFS.
I want to know if , there is a good and credible solution for this ,to enable me use crucible with TFS.
additional , if there are another suggests for code reiview tool for VS and JIRA.
Thank!
Some time ago we decided to run Crucible on our project. Our project uses TFS 2012. We use one branch in TFS called 'dev' as a trunk, i.e. branch where developers make commits and where raw code located. Second branch where release code located called 'main'
Our workflow for peer review was:
Make some changes and shelve code
Send email to reviewer
Reviewer doing review in some custom tool and send email with notification that he is done
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
Our goal was to improve step 2 and 3. Crucible is great tool, but it doesn't support TFS out of the box, thus we decided to use some TFS bridge. Actually, there are two main options either using tfs->svn or tfs->git. Finally, we decided to use tfs->git bridge, because creating branches in git extremely cheap and it might have been helpful (it did), because we was thinking use branches in git for out shelvesets in TFS. Finally we made our mind to use git.
So far I know only 2 options to convert TFS into git:
git tf - this one works on Linux and recommended by Microsoft
git tfs - this one works only under Windows, but we choose this one, because of large set of commands
We need to convert TFS branch into Git repo and maintain our git repository in fresh state. We don't work with git to push new changes back into TFS, we need git repo only for Crucible.
There are steps we made to achieve the goal:
1. Firstly, we cloned our TFS "dev" branch into "dev" repo. We needed only this one branch, and we haven't any back merges from "main" branch. We have tried to do this with clone command, but without any luck:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
This command cloning full history from TFS, but it seems our TFS branch quite large and at some time git-tfs crashed with System.OutOfMemoryException exception. Another time, we failed with exception that max limit of path was exceeded, we found workaround by mapping workspace dir into as short path as possible as follows:
git config --global git-tfs.workspace-dir e:\ws
When we failed with clone command, we went to use quick-clone command. This one cloning starting from any time in history, from any changeset.
git tfs quick-clone -c545532 http://tfs:8080/tfs/DefaultCollection $/SOME_PATH/dev
Option -c545532 here is the number of changeset to starting copying from. Once per year we update all our source files with new header, thus we just to copy from beginning of current year. In that way we should have all necessary history to make branches from shelvesets.
If you hadn't used -c argument here, you would have haven't any history at all, because quick-clone copies just history if you asking for it.
Once repository was cloned, we had written "script" and put it into task scheduler to run every 5 min. What script is doing is just checking for new commits in TFS and creates new branches on our git repository. Again, we use git-tfs here. To get all new commits we call pull command:
git tfs pull
To unshelve TFS shelveset into particular git branch we use unshelve command:
git tfs unshelve -user=TFSDOMAIN\Username "Shelveset Name Here" Branch_Shelveset_Name_Here
This last command creates branch 'Branch_Shelveset_Name_Here' in git from shelveset 'Shelveset Name Here' in TFS. A shelveset's name can contains spaces and some escape chars, so our "script" clean up such cases. As I said, creating branches very cheap on git, thus we haven't any problems with this. If something was pushed into git repo we call crucible API to refresh it.
BTW: To make git repo visible in network I just installed SCM-Server. Crucible was installed and configured to use our domain username/password, thus we get email notification as well. As result we drastically improved step 2 and 3 from our workflow and it works for few months and we are happy with it.
Our workflow became:
Make some changes and shelve code
Wait for our shelveset in crucible (about 6-8 min), create review
Reviewer doing review in crucible
Commit code into 'dev' branch on TFS
Wait while build-server makes successful build
Commit to 'main' branch where production code resides
While working with this I noticed few issues:
Issue1: If you added new file into project and shelved it, you would not see it in git repo, because git-tfs can't find parent commit for it. I'm not sure is it bug of this tool or not, but simplest workaround for this, is having at least one file in shelveset with existing parent. For example, you have added 2 new files and want to send it for review. Instead of creating shelveset with these files, just touch any file which already in git repo (make it pending in Visual Studio), finally you will be able create shelveset with three files (2 new files [add] and 1 for edit [edit]). In that case everything works and git-tfs can unshelve TFS' shelveset into git branch., i.e. we can see it in crucible.
Issue2: One day our HEAD in git repo became detached from "master" branch. Once that happened crucible didn't see new changesets. I have fixed it with command:
git rebase HEAD master
I have created picture how this everything works on our project, may be it could be helpful:
You can integrate Mira and TFS with TaskTop and then use the code review tools built into Visual Studio.
Code Review added in Visual Studio 2012
TaskTop integration with TFS & Jira
These I think are your best options.

Resources