connect to azure devops repo - locally existing solution - azure-devops

I have an existing visual studio solution which was cloned from a git repo (in azure devops). I recently reinstalled windows and vidual studio 2019. The solution is still there in my computer. I just need to connect the same to the repository in devops.
I connected to the azure devops account using team explorer (after opening the solution in visual studio). The connection happened, but the solution files are closed and there is only option to clone the repository (see screenshot)
If I click on "Git changes"/ "Git repository" , it takes me to the git menu which has only option to create or clone repository.
Even without the team explorer, the only git options that I can see are clone or create.
What am I doing wrong?
what is the correct way to connect exiting repo without cloning?

In the toolbar try clicking Git --> Manage Remotes. I'm assuming these are blank due to reinstalling windows. Click add, name it origin and add the clone url from the relevant azure repo for both Fetch and Push.
This can also be done using git bash by CDing into the solution folder and using the following command
git remote add origin [repo-url]

Related

How would I add associate a remote GitHub repository to a local repository in the Visual Studio 2019 Team Explorer?

How would I associate remote repository from the Visual Studio 2019 Team Explorer to a local repository? There does not seem to be any way to specify the GitHub URL of a remote repository in Team Explorer or Visual Studio 2019.
The steps I am using are below.
Create a new solution in Visual Studio 2019.
Do a File | Add to Source Control to add a local repository.
Go to GitHub on the Internet and Sign In.
Create a new repository with a ReadMe and Visual Studio setting.
Copy the URL for the newly create remote repository.
Switch back to Visual Studio 2019.
There is no setting in the Team Explorer to specify the URL for the remote repository. How would I specify the GitHub repository in Team Explorer or Visual Studio 2019? Is there any way to Publish in Visual Studios 2019 for Windows or is this only available for Mac?
If there is no obvious settings in Visual Studio itself, you can switch back to command-line, and go to the root folder of your project/git repository:
git remote add origin https://url/to/new/repo
git branch -u origin master
git stash
git pull --rebase
git stash pop
git push
The first pull --rebase is necessary to replay your local commits on top of the remote GitHub master commit (with its README and setting files)
Then open Visual Studio back up, and check it detects the association between your local repository and your remote GitHub one.
You can configure remotes in Team Explorer, although the setting is a little buried. In the Team Explorer Settings page, click the link for Git Repository Settings, and there should be a section that holds the remotes. You can add or edit remotes there.
Hope this helps.
If you are using the new Git experience, this is located in the top level menu [Git] > [Manage Remotes...]
Accessible top level Git menu

Sync some projects from Azure Devops to Github or another solution?

I have a big .NET solution with many projects. Everything is on Azure devops, and working well for the team.
Some of these projects are demo project.
I would like a way to publish the code of these demo projects on github, so they will be publicly available.
I'm looking for a way to publish the code of these specific projects to github.
Does anyone have a way to do that efficiently ?
if you are using any previous source control (ex TFS) first Unattache it ,
i presume you are using VS,
right click the solution then select "Add solution to source control "
since VS 2015 , GitHub is integrated out of the box , log in to your GitHub account(if you are using an older version just download it as an extension )
Below are the visuals
Create a new folder.
Copy to this folder only the projects you want to publish on GitHub.
Create a new Git repo:
git init
git add .
git commit -m "first commit"
Create a new repo on GitHub:
Open cmd and push the new local repo to new GitHub repo.
cd path/to/your-new-folder
git remote add origin https://github.com/{your-user-name}/demo-projcets.git
git push -u origin master

Is it possible to push to a new remote on VSTS git?

Is it possible to create a new VSTS Git remote repository from a Git client?
Right now, I have to go to visualstudio.com first to create the new repository before adding and pushing it from PC git, using the url created in VSTS.
I tried the following:
git remote add brandnew xx.visualstudio.com/PROJECT/_git/qqq
git push brandnew --all
where I am the owner of xx.visualstudio.com and PROJECT is an existing project, but qqq does not exist.
The above gives me:
remote: TF401019: The Git repository with name or identifier qqq does not exist or you do not have permissions for the operation you are attempting.
fatal: repository 'https://xx.visualstudio.com/PROJECT/_git/qqq/' not found
Yes, it's possible.
Even you can not create a VSTS git repo by git command line by default, but you can achieve it via git hooks.
And for the reason why you can create and publish new VSTS git repo via VS, it that VS will create the new VSTS git repo by API not by git commands.
So if you want achieve this feature in git command line, you can use pre-push hook for assistance. Functions need to achieve in pre-push hook as below:
Detect if the remote repo https://xx.visualstudio.com/PROJECT/_git/qqq exist or not.
If the repo is not exist in VSTS, then create by REST API.

Cancelling Version Control in Xamarin Studio while sharing with Github

initially i was trying to commit a project to github , then accidentally i didn't commit the project well, now am trying to remove Version Control and switch it again to Commit the project to Github.
I want to see this :
But am seeing this :
How can i Commit again , to github?
I recently just had this problem and asked the wonderful people at Github.
Note: I reset up a new repository, to commit to. I deleted the old one I had messed up. But still could not use Xamarin to Publish. Even after changing the remote connection in version control to the new repository.
This was the solution they provided me with:
From Github
I'm not familiar with the tool that your using to push to the repository but I can help you do this via the command line if that works for you?
Once we get the project pushed to GitHub I think should be able to clone it again to a fresh location on your computer and then link this into Xamarin hopefully.
The steps to push this from the command line would be:
Open the Terminal app and change directories to the location of the project on your local computer.
The command to change directories would be cd <full path to the projects location>. For example if your project was located in your documents folder
cd ~/Documents/projectname
Once there, you need to initiate the project for git version control, commit the project and link up the GitHub repository. To do that you can run the following commands one after the other:
git init
git add .
git commit -m `First commit`
git add remote origin https://github.com/yourrepository/project.git
The last step would be pushing to GitHub:
git push origin master
We have a help doc that has some instructions for this below:
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
Let me know if you run into any trouble with that!
The only thing they did not mention was that you will be prompted for a username and password. This is the username and password for Github (not the token created for the repository)
Also in the linked documentation, in the above they use:
git push -u origin master
as the last step, I got an error when I did not include the -u
I also did not need to clone it.
The remote connection in Xamarin now links to this new repository. I have made and committed some changes to check.

Can't checkout remote branch using GitHub Desktop

When I first clone a repo using GitHub Desktop (windows version), I'm able to see all of the branches and can checkout the branches.
However, if another contributor creates a new remote branch (after I've done the clone), GitHub Desktop isn't able to fetch and checkout the new branches. The branches are visible via the GitHub website. The only way I've found to checkout these branches via GitHub desktop is to delete the local repo and clone again. I was expecting the "Sync" button to handle fetching new branches from the remote repo.
Any ideas?
According to Steve Ward at GitHub Support:
You should be able to hit F5 in GitHub Desktop to refresh the repository and fetch any new branches from the remote repository. There currently aren't any animations for this process, but it should work without issue. [...] we automatically fetch new branches every five minutes as well.
You can also click on the "Gear" button in upper right of the client, select "Open in Git Shell" and type the command git fetch in the command window that is opened...