Migration from TFVC to Git - how does it handle branches? - azure-devops

I'm looking into migrating our TFVC repository to Git using the "Import" option provided in Azure DevOps (Repos -> Files -> [New Git Repository] -> 'Import' button).
Our TFVC repo currently has two branches:
$/MyProject/Dev
$/MyProject/Release_1.0 (currently our one and only production version)
The documentation for the "import" option (here) says that "only a single branch will be migrated". If so, how can I migrate both branches to my new Git repository and keep the "relationship" that the branches have with each other? i.e. once in Git I still want to be able to (say) fix a bug in the "Release_1.0" branch and merge the change back into "Dev".

For this issue, agree with Daniel , you can use git-tfs to achieve this migration.
First fetch all the source history (with all branches) in a local git repository:
git tfs clone http://tfs:8080/tfs/DefaultCollection $/project/trunk . --branches=all
Wait quite some time, fetching all the changesets from TFS is even longer.
Pros:
you have all the whole history in the git repository
manage merges between branches! A branch merged in another one will
be materialized in the git repository.
For details ,please refer to this document and issue(clone multiple TFS branches into one Git repo).

Related

Whats the easiest and noob friendly way to move changes from github to tfs?

I have a project hosted on TFS, let's call it GenderBlender. Two teams work on GenderBlender. One team got the latest code from TFS and hosted it on Github. Made some commits to that GitHub. How can I move those changes from Github to Tfs without commit history and just one big commit under my account?
I will be moving it from my local git repository to my local tfs repository and then committing them to the tfs.
That is actually the idea: copy the all files from the Git repo to the tfs working tree (be it a TFVC workspace or a Git one)
If it is a Git repo, Git will detect the changes: add and commit.
If it is a TFVC workspace, use a reconcile command to detect the changes

Merge GitHub branch into local branch

I have the following situation: I have an application checked out from GitHub, made some changes and checked it in a local repository (Bitbucket). During months I added new functionality into this local repo.
In the meantime, the GitHub project has been further developed.
Now I'm looking for a way to merge the GitHub master branch into my local master branch. It would be nice if I can do it in eclipse. How should I proceed and how can I avoid conflicts?
In the Git Repositories view:
Add an additional remote/upstream repository: right-click the node Remotes and choose Remote Remote...
Fetch from the GitHub repository: see EGit User Guide - Fetching from other Repositories
Merge changes from a remote branch of the GitHub repository into a local branch
Consider also to contribute back your changes to the GitHub project.

How to convert a remote branch into a local one in Eclipse using Bitbucket?

I'm kind a newbie on Bitbucket so I have a lot of doubts.
I share an Eclipse project between two different computers. I have pushed the project from one computer to the Bitbucket repository using the Eclipse plug-in. Now when I go to the other computer I have fetched the repository that is saved on Bitbucket, and it has created a new remote tracking branch on my Eclipse local repository.
My problem comes when I want to merge that branch with the local branch, I have no idea how can I do that
Anyone could help me?
ps: sorry if the problem or the situation is not very clear
You should follow the section "Pulling New Changes from Upstream Branch ":
a git pull is a fetch + a merge.
Right-click on a project in the Package Explorer and select Team > Pull or right-click on a repository in the Git Repositories view and select Pull to pull new changes from the upstream branch your local branch is tracking.
The section "Fetch and Pull" of the Egit tutorial says as much:
When cloning remote repositories, Git creates copies of the branches as local branches and as remote branches.
A Fetch operation will update the remote branches only.
To update your local branches as well, you will have to perform a Merge operation after fetching.

Integrating Github code to TFS - auto check-in

We are using one of the project from Github. We need to check-in code of this project in our TFS.
We need to automate this process. Else everyday we need to download the code and then check-in.
Is there some plugin or some tool to automate this?
If you are using a TFVC repository in TFS then you'll probably want to build some scripts and a process around Git-TF to help automate some of this work.
If you are using a Git repository in TFS then you can create set up two remotes in a local Git repository, i.e
git remote add upstream https://github.com/foo/bar.git
git remote add origin https://tfsserver/DefaultCollection/_git/bar
And then simply do a git pull upstream master followed by a git push origin master assuming that master is the branch that you want to keep in sync.
With either version control system, you probably want to keep a branch in version control in your TFS repository to match what is in your upstream GitHub project so that you can easily see change coming in the one place and then handle your merges inside your local repository.

From github to bitbucket

Imagine situation like this:
You have a working repo in bitbucket - you were pulling revisions from another bitbucket repo in Windows 7 through TortioseHG.
Now the second project has moved to Github system and you can not pull from it anymore.
So my question is like this:
How can i somehow create new repo in bitbucket where I will pulling changes from github and from this repo i can easily pull in Tortiose HG to my working repo?
I do not want to use Github etc, so please do not advice it to me etc just help me with my question. Thank you.
The ideal solution consiste to keep local Mercurial repo, and work only with this local repo to the existing bitbucket Mercurial remote repo.
With a plugin like Hg-Git, you can at least push to and pull from a Git server repository from Mercurial, allowing you to pull from the GitHub repo to your local Mercurial repo.
From that local (Mercurial) repo, you can then work as usual with the bitbucket remote repo.
The OP adds:
It didn't work for me so i tried to transfer git repo to hg repo and from this repo pull to my working repo with changes - but it says that: abort: repository is unrelated - but I merged a lot from it. Any help here?
That makes senses, if both repos have been developed separately, you cannot push/pull 2 (mercurial) repos one into another.
This is confirmed at the bottom of the page "Understanding Mercurial", and detailed in the blog post: "What Mercurial Can't Do: Subtree Repos".
The more practical solution would be to make one extra repository (a "parent one") with your two repos declared in it as nested repository.
It would keep both repos independent, allowing to push back to the GitHub repo from your second mercurial repo.
If you don't have to push back to GitHub, but really want to have one repo in which you merge common files, then you can look in "Merge tip from an unrelated repository with Mercurial", but that is much more complex.
I would rather:
keep both repos separate
delete from the first one the common files you need to merge in the second one.
report and merge those common files in the second one.