Reputation: 737
About a week ago Git support was added to Visual Studio 2012 and Team Foundation Service. I've been playing around with it a bit and wanted to publish a local repository to my team project. It's described in step 2 on the Team Foundation Service website:
Now I've been doing the exact same thing, but I don't get the "Publish to ..." context item. Could this be a bug or am I missing something?
Upvotes: 20
Views: 18570
Reputation: 346
Create the project in VSTS/GitHub/somewhere, then from Git Bash...
git remote add origin https://xxx.somewhere.com/_git/xxxProjectNamexxx
git push -u origin --all
Upvotes: 0
Reputation: 176
Same problem here, except instead of editing git config files, just delete the entire git repository folder for the project. Reload the project and start over with Source Code action under file. Then add all changes to the project to the local Git. Then "Sync" and it will display the url textbox.
Upvotes: 0
Reputation: 571
I can confirm other answers, that the GIT repo cannot have any remotes listed or VS13 won't add it to the team project. I was using Atlassian tools Stash / Bitbucket / SourceTree and as soon as I closed VS13, removed all the remotes, reopenened VS13, opened the team project, and right clicked on my local GIT repo. The option "Publish to {teamProject}" was available and the .sln was then available by opening the team project.
Upvotes: 1
Reputation: 279
In the Team Explorer window find your repository under Local Git Repositories. Right click on the one you want to change and pick Open Command Prompt.
Now type git remote -v
and it should show you the remote name and the complete url for it.
type git remote remove origin
assuming origin is the name of your remote repository. Then git remote add origin [url]
replacing [url] with the actual url of your repository.
Now you should be able to push your master branch into the repository for your team project.
Upvotes: 1
Reputation: 57
I had the same problem today, I was not understanding why this "Publish to..." menu didn't appear. I found that it's because you have to map one online repository to a local one, no more.
In your example, it seems Gittyup online is already mapped to Gittyup local, so you have to create a new Git project in the web interface, then you connect to it in VS, and then you can publish your local repository to the online one.
Upvotes: 1
Reputation: 1784
I had the same issue. I had to delete all of my remotes in .git/config (not just origin) before the Publish option is available. Apparently, Microsoft assumes you would never even dream of using a different remote.
Upvotes: 2
Reputation: 11
For submitting an existing local repository to TFS-Git:
While setting up my account at TFS, I did set up an alternate credentials, though I am not sure if they were needed for this process.
I am new to GIT and TFS, but this process allowed my to push two of my solutions, each with three projects into TFS. Also, within Git Extensions, I found that I could organize my local repositories into categories, which proved a convenient way to organize my projects into their solutions. I would like to do the same in TFS, too.
Upvotes: 1
Reputation: 347
I tried all of the above but the only way I could get it to work was to use git hub for windows.
To make that work you will need to set up alternate credentials. https://tfs.visualstudio.com/en-us/home/news/2012/aug-27/
Upvotes: 1
Reputation: 742
I had this same exact problem. I was able to resolve it by restarting Visual Studio completely, opening Team Explorer, then navigating to my local repo. I opened up my local .sln, then clicked on "Changes", "Commits" and it then had an area where I could Publish the project to a URL. I took that URL such as: https://myapps.visualstudio.com/DefaultCollection/_git/MySolution and then clicked "Publish" (I had to do it twice.) I can now commit to the TFS and view my code online.
Upvotes: 3
Reputation: 12799
I found it helped to start a new solution and publish from there going step by step.
Once it's 'confused' itself it's best to start the process over. I got it working and never had to edit that file.
Upvotes: 1
Reputation: 3186
I was just having the same problem, and the answer by ngm didn't work; I had to do the opposite. The [remote "origin"] section was already in my .git/config file, however the project code wasn't uploaded to TFS.
To fix it I just deleted that section from the config file, then restarted Visual Studio and followed the official instructions.
Upvotes: 6
Reputation: 7487
I was having the same problem. I don't know why.
However, after a bit of playing around, I managed to get the following working. Disclaimer: can't guarantee this is actually the correct way to do it. It may bork things further. And whether it does the same as what the missing 'Publish' menu item is supposed to do, I have no idea. Use at your discretion...
e.g.
[remote "origin"]
url = https://user.visualstudio.com/DefaultCollection/_git/YourRepo
fetch = +refs/heads/*:refs/remotes/origin/*
This should hopefully push your local repo to your TFS remote as origin.
From here things seem to be working for me -- the code is up in my TFS web interface at least, and I can push commits to it. I can add backlog items etc. I'm new to TFS though so not sure if it's actually all working as it should be.
Upvotes: 12