Convert Git into TFVC with history - tfs

Is there any tool to convert Git Repos into TFVC with history or convert TFS into TFVC including the history?

Git-TFS will do this, but be aware that TFVC and Git are very different models for source control so the tool may not be able to get all history of all branches. Some historic actions inside TFVC may cause the tool to fail (such as branch Renames).
The best way to figure out if you have a problem is to run the tool against your TFVC instance.
run something like
git tfs clone http://tfsServer:8080/tfs/DefaultCollection $/Project1/Trunk --branches=all
Or
git tfs clone http://dev.azure.com/organisation $/Project1/Trunk --branches=all
And see what happens. This command will create a local Git Repo which you can look at to ensure all of your branches and history have been converted

Related

Clone GIT to TFS (AzureDevOps) with git-tfs

we have an local DevOps Server 2019 with our old projects and I am able to clone this projects with git-tfs to local Git repositories. Everything is fine. After that I can push this repositories to our AzureDevOps Git repositories. Everything ok.
Now we have some projects and colleagues who want to use TFVC for these special projects. So my idea was to clone these projects from local TFS to Git and then use git-tfs rcheckin to push it to our AzureDevOps project.
But when I use "git-fts rcheckin --remote azuretfs" I get "error: latest TFS commit should be parent of commits being checked in"
When I use "git-tfs checin --remote azuretfs" all files are uploaded to the AzureDevOps project but without the history.
So can anyone describe what I have to do?
Note: I don't want to use the MigrationTool offered by Microsoft because of to many erros during validation the templates of work items etc. (we dont use it...)
For those who are looking for the same:
With the 'old' git tf tool (https://archive.codeplex.com/?p=gittf) you can migrate old TFVC project to Azure DevOps(TVFC).
If you want to migrate old TFVC projects to AzureDevOps(GIT) you should use git tfs (http://git-tfs.com/)
What you could try without guarantee of success...
Note: As I said, you will be able to migrate the history from one branch only.
Create the folder/project in TFVC where you want to put the source code.
Migrate this folder with git tfs clone (to have a git commit with the git-tfs metadata required to rcheckin)
Add the already migrated history repo (let's call it RepoWithHistory) as a local remote in this new repository (let's call it NewRepo). And git fetch
Clean metadata for only the commit coming from RepoWithHistory with something looking like: git filter-branch -f --msg-filter "sed 's/^git-tfs-id:.*$//g'" -- --all. But be careful to keep the metadata on the commits coming from NewRepo.
Use git replace --graft <sha1_of_first_commit_of_RepoWithHistory> <sha1_of_last_commit_of_NewRepo> to graft the 2 histories (the history must be on top of the one from the new one)
Use git rcheckin --no-merge to migrate the history to TFVC (that will be long...)
I hope it will help.
PS: perhaps you should try to do it on a small subset of commits to be able to verify it will works before doing it in the real TFVC project.

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.

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.

Pulling changes from TFS with git-tf

In our company, git is not supported, only TFS is. In my team however, we all use git and before using git-tf we were using git-tfs. A few days ago me and another colleague decided to give git-tf a try, so we did a git tf clone --deep of our project from TFS. That worked fine and we can see all changesets as separate commits in the treeview.
Some of our projects are shared with other teams, so other people will make changes and use only TFS to push their changes. What I've noticed is that even though I'm using git tf pull --deep, all changesets are being bundled in just one commit that contains all the files that were changed. Even if in the TFS history I can see that there were 10 changesets made by the other team in the last day for example. I'm only seeing 1 new commit in my history.
When reading the git-tf documentation I see this:
Pull
git tf pull [--deep] [--rebase]
Fetches changes made in TFS as a new
commit in Git, and merges the commit with the latest commit in the
current branch. By default, the fetch performed by the pull command is
shallow, but the --deep option may be used to create a Git commit for
each TFS changeset created since the last fetch. Also, merge is used
by default when pulling, but the --rebase option may be used to
perform a rebase instead.
What am I missing? What command do I have to use in order to get each changeset as a new commit on my local git branch?
EDIT 1-6-2016
Since it's been quite a while since I've asked this question and no answers have been posted, this question can be closed/deleted. Maybe in a future version of git-tfs this will be made possible, I'll keep an eye on it.

Git repository and TFS repository

Once upon a time we had a TFS repository. We wanted to move to Git. At the time we took just the latest working version, copied that to a new git repo and started working on that.
However due to decommissioning of TFS we'd like to clone the TFS repo to Git (with git-tf) and rebase our changes on that.
Is this possible?
Assuming you are just talking about the source code (TFS is also a work item tracker, build server among other things)
the --deep argument will clone all TFS changesets
git tf clone <tfsurl> <teamproject> --deep
update: bear in mind that this doesn't take into account linked work items, branches, tags.
beware: this will take a while for large repositories...
further reading: http://gittf.codeplex.com/wikipage?title=Clone&referringTitle=Home

Resources