0
votes

I don't know what the best way is to setup Visual Studio and a remote Git repo and link them together. I've looked at some videos and read some articles but I'm still getting the "rejected updates because the remote contains work that you do not have locally". Here are the steps I took. Can someone tell me the step I'm missing or if there is a different way I should go about doing this?

  1. Created a remote Git repo through our TFS website. This is an on-premise server.
  2. Cloned the remote repo down to C:\TFS\Projects\RepoName.
  3. Opened Visual Studio 2017 and created an new console app. I pointed the folder to the C:\TFS\Projects and name the project the same as the RepoName I used in cloning. I unchecked the "Create Folder" and "Add to Git" boxes.
  4. In VS went to File | Add To Source Control.
  5. Added a test file and then tried to Sync to the remote repo and get the error.
1
If you use the git command line to push, do you get the same error?Andy
I get "Updates were rejected beause of the tip of your current branch is behind it's remote counterpart".Caverman
You might try running git pull to retrieve the latest changes, then.Andy
I just tired "git pull origin master" and get "refusing to merge unrelated histories"Caverman
Maybe try rebasing intead: git pull --rebase origin masterAndy

1 Answers

0
votes

What exactly you have done is created a new project on Remote, Cloned it on Local, then added new folder and files replaced with remote folders and then tried to add the files using VCS to source code.

There are multiple way of doing what you're doing, it seems like you are just a beginner i would suggest,

Create local repo and push that on Remote. Instead of doing other way around.

You can follow this doc to do this,

https://docs.microsoft.com/en-us/azure/devops/repos/git/share-your-code-in-git-vs-2017?view=azure-devops