Microsoft now has support for Git repositories on their Team Foundation Service. I have an account on Team Foundation Service, and I\'d like to push my existing Git reposito
Okay, I was apparently overcomplicating this. Here's what I did.
git pull c:\source\oldGitProject
That was it, it pulled all of the changes from the old location, and I could push that up to TFService easily.
Ran into this problem today.
VonC's answer, adding TFS as a remote and using git push --mirror tfs
, worked for me.
However, it might be beneficial to mention some additional things about this.
After the push, Visual Studio is still unable to identify that this local repo is connected to the Team Foundation Service in any way. So, you'll still need to select "Connect to Team Project..." and do a 'clone' using the interface. The repo from TFS will be cloned, with everything to just pushed. After this you'll be connected to TFS, and should be able to work normally in the clone.
Using '--mirror' will push all local references, potentially including some local branches that you don't really want to have in the central repo.
If this is the case, after pushing with '--mirror', you should use git push tfs :<branchname>
to delete a branch from TFS in order to avoid other people later pulling your local branches.
Alternatively, instead of '--mirror', it should be possible to just push the desired refs into the TFS repo, just like you would any other git repo: git push tfs <refspec>
. Since the TFS repo is still empty at this stage, a bunch of branch names one after the other should be enough as a <refspec>
. If using this method you could also use use git push -u
, which will also make the branches you push into the empty repo tracking branches.
EDIT: As mentioned in Edward Thomson's comment, cloning from TFS should be unnecessary if your original repo is configured to track a branch from the TFS remote. So git push -u <refspec>
should both push the repo to the empty TFS repo, and also allow the IDE to recognize the original local repo because it sets up tracking.
"how do I push my existing git repository to TFService?"
Once you have declared a git repo on tfs.visualstudio.com (see below), add that git repo url to the remotes of your own local repo:
cd /path/to/local/repo
git remote add tfs url://tfs/git/repo
git push --mirror tfs
That will be enough to push the full history of your local repo back to that new upstream repo on TFS.
Again, the idea is to create a new empty repo on the upstream side (TFS), and to push your local repo to it.
(Original answer)
If I understand Scott Hanselman's blog post about it:
This Git support will require VS2012.2 (currently in preview) so you'll need to install that first, then get the VSIX. You'll be able to update both when VS2012.2 is released, and the Git VSIX will continue to update automatically via the VS Gallery.
It's a full source code provider for VS so you can use it to do most anything without leaving VS, or you can hang out at the command line and use it for a visual reminder as to the state of your repository.
For teams, you can go up to http://tfs.visualstudio.com and sign up for a account and get 5 users for free. You can choose either Git or Team Foundation Version Control (TFVC) as the source provider and use all the Team Foundation agile, scrum or other templates for your ALM tools
The registration process for a Git project is illustrated here, again pointing out that you need the “community technology preview” of the Git VSIX on top of a “community technology preview” of VS 2012 Update 2 (VS2012.2).
All we need do is change the server target url of the existing local solution/repo.
So:
On your local machine, open the existing solution/repo in Visual Studio and in the Package Management Console (PMC) run the following command
git remote set-url origin https://new.url.here
Using View>Team Explorer>Unsynched Commits push the existing solution / repo to the new project.
This will push the local repo, including all previous commits, to the new TFS project in the cloud.
Git command line FTW.
All this doing is updating the [url origin] attribute in the config file found in the .git folder, so you could just use notepad if you wanted to open and edit this file. IMHO this command is cleaner because you don't run the risk of accidentally editing some other setting nor do you have to leave VS.
Note: If the option to Push in step: 3 is disabled then you may have to perform another local commit in order to "dirty" the head of your source tree and thus enable the push command. Tho I'm sure there would be another git command to do this as well.
Some good answers above, but I found this even easier.
The screen will show the exact Git command to push an existing repository, including the URL for your unique repository. All you have to do is copy and paste that command into your Git command prompt.
git clone <repository url>
One of the blogs I found this morning linked this document:
http://blogs.msdn.com/b/visualstudioalm/archive/2013/02/06/set-up-connect-and-publish-using-visual-studio-with-git.aspx#publish-tfs
They appear to have an internal command called publish (which might be using the --mirror command that @VonC mentioned?)
I'm not sure if this works yet either.