none
How can I add an existing solution to a new Git repository?

    Question

  • I've installed VS2012 Update 2 CTP 2 and have connected to my TFS repository at VisualStudio.com but I'm a little stumped in step 2 here:

    http://tfs.visualstudio.com/en-us/learn/code/publish-new-team-project-vs-git/

    The Publish to {Repo Name} option isn't available to me.

    I have a Solution file, and I have a repository - but I'm trying to figure out how to add the contents of my solution to the repo.

    I know Git support is new (and I'm probably overlooking some obvious thing), but hopefully someone else has figured it out. I'm kind of new to Git - but I've used TFS, SVN, and VSS extensively. It's always seemed pretty intuitive to add files to source control.


    "We're all in it together, kid." - Harry Tuttle, Heating Engineer


    • Edited by Bleak Morn Wednesday, February 06, 2013 8:08 PM
    Wednesday, February 06, 2013 8:07 PM

Answers

  • If your solution is already within the Git repo directory on disk, you should be able to right click the solution and choose the 'Add to Source Control' command to get that solution into the repo.  If the solution is currently outside the repo directory, you'll need to move it.

    The 'Publish to {TeamProjectName}' command is only visible if several criteria are met:

    1. You are connected to a TFS team project that uses Git for source control.  That project will be bolded in the Team Explorer Connect page.

    2. You do not already have a local cloned repo that for that team project.  In other words, there's not already a repo in the list that has the origin remote pointing to the current team project.  If you have a cloned repo, then the publish is more than likely to fail since the remote repo is probably not empty.

    3. The local repo has no remotes.  We are listening for feedback on this, but the idea is if you are using this local repo with another service (ex: GitHub), then we don't want to nag you about publishing it to a TFS team project.  We want to enable you to work just fine with any hosted Git service without being pestered to use ours. :)  Therefore, we don't show this Publish command if there are any remotes set in that repo.  We take that as a sign that you are already using this repo with another service.

    Hope this helps make things more clear.  If you would like to keep your remotes and also push to TFS, you can push it from any Git command line.  The URL to use can be located in your website for your TFS team project.  If you'd like to push this repo to TFS from the VS UI, you would currently need to remove the remotes for the repo.

    If you feel your scenario is not properly covered by the criteria above, we'd love to hear how you would expect it to work so we can incorporate the feedback into future design discussions.

    -Chad

    Wednesday, February 06, 2013 8:42 PM

All replies

  • If your solution is already within the Git repo directory on disk, you should be able to right click the solution and choose the 'Add to Source Control' command to get that solution into the repo.  If the solution is currently outside the repo directory, you'll need to move it.

    The 'Publish to {TeamProjectName}' command is only visible if several criteria are met:

    1. You are connected to a TFS team project that uses Git for source control.  That project will be bolded in the Team Explorer Connect page.

    2. You do not already have a local cloned repo that for that team project.  In other words, there's not already a repo in the list that has the origin remote pointing to the current team project.  If you have a cloned repo, then the publish is more than likely to fail since the remote repo is probably not empty.

    3. The local repo has no remotes.  We are listening for feedback on this, but the idea is if you are using this local repo with another service (ex: GitHub), then we don't want to nag you about publishing it to a TFS team project.  We want to enable you to work just fine with any hosted Git service without being pestered to use ours. :)  Therefore, we don't show this Publish command if there are any remotes set in that repo.  We take that as a sign that you are already using this repo with another service.

    Hope this helps make things more clear.  If you would like to keep your remotes and also push to TFS, you can push it from any Git command line.  The URL to use can be located in your website for your TFS team project.  If you'd like to push this repo to TFS from the VS UI, you would currently need to remove the remotes for the repo.

    If you feel your scenario is not properly covered by the criteria above, we'd love to hear how you would expect it to work so we can incorporate the feedback into future design discussions.

    -Chad

    Wednesday, February 06, 2013 8:42 PM
  • For the first part of your comment, I had copied the files to the repo directory.  When right-clicking on the solution I didn't see an 'Add to Source Control' option - that's what I had been expecting to see before I posted here.  I don't see it in the list (not even grayed out).

    I also checked in Explorer and saw some Git commands, but "Git Add all files now" (which seemed promising) didn't seem to do anything.

    * * *

    I read on and saw the part about the cloned repo and navigated to the folder, then deleted it.

    This allowed me to see the Publish to {TeamProjectName} menu option and I clicked it, resulting in the message that The origin remote has been added and the current branch has been published.

    After I saw that, I could no longer see anything in Solution Explorer - just a wrench icon that was active.

    I right clicked on the local repository, Open in File Explorer, then clicked on the solution to open it and things seemed to work.  So my issue is resolved - but it was kind of  a bumpy road.

    Hopefully my experience can give some insight.  I think the two biggest issues were the lack of "Add to source control" in the menu for some reason - and the Solution Explorer losing it's content for some reason. I think those were the main roadblocks.

    Thanks for the help!


    "We're all in it together, kid." - Harry Tuttle, Heating Engineer

    Wednesday, February 06, 2013 10:01 PM
  • Thanks for the additional info.  I've noted the order of the steps you took so we can try to improve the user experience in this scenario.

    -Chad

    Wednesday, February 06, 2013 10:07 PM
  • I'm a little late to the party, but luckily for me I stumbled onto this thread. Opening the repo in File Explorer and opening the .sln file through that was what made the process work as (mostly) documented.

    It's September - seven months since previous postings on this thread, and my two cents' worth is that it's still a problem. In my case, it seemed to have more to do with converting an existing VS2012 project to use TFS/Git (I don't think I saw any explicit docs on this) - plus, of course, unfamiliarity with Git.

    Thanks, guys.

    Tuesday, September 17, 2013 10:33 AM