Import a vs 2017 solution git repo into azure devops - azure-devops

I am trying to use appcenter with azuredevops services.
I have created a solution "HelloWorld" on local PC in VS 2017 and added to local Git repository
I have created a project in AzureDevOps "MobileApps"
How do I import my new shiny solution in VS2017 "HelloWorld" into AzureDevOps?
Any walkthrough?
I can make it work if
I start from azuredevops and clone in visual studio.Bcse I then get a prompt in visual studio to create a new solution in the new cloned repo.
But Cannot find a way to import a repository from Visual studio into AzureDevOps.
Links that i saw but did not work .Also outdated with azuredevops.
How to Import project code from local machine to Azure Repos?

You should be following these steps to add your local git repo to Azure DevOps
Create a git repo in Azure DevOps repos
Copy the clone url from Azure DevOps and use below command to configure your local repo to use Azure DevOps repo as the remote repo. Edit command from local git repo root folder.
git remote add origin <url-from-Azure repos>
Then you should be able to push your local content to Azure repos..you can use below commands
git add .
git commit -m 'your comment'
git push -u origin master

Related

connect to azure devops repo - locally existing solution

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]

how do i automatically pull code from master to fork in azure repos using azure devOps pipeline

I was trying to pull the code from master to fork repository automatically through the azure pipeline. If any one know about this?
If you fork azure repo and want to automatically sync the Fork repo using VSTS Git, please follow below steps.
Supposed the url of original repo is https://dev.azure.com/{organization}/{project}/_git/test, and the url of forked repo is https://dev.azure.com/{organization}/{project}/_git/test_fork.
If you click "Clone" button in test repository, you will see below panel.
Clicking "Generate Git Credentials" button will show the following panel.
So we can use command git remote add upstream https://username:password#dev.azure.com/{organization}/{project}/_git/test to specify it as the upstream of test_fork repo in script.
Now creating a build pipeline using Microsoft-hosted Windows agents, setting the test_fork as the source.
Adding the Command Line task with below script.
git remote add upstream https://username:password#dev.azure.com/{organization}/{project}/_git/test
git fetch upstream
git rebase upstream/master
git push -f origin HEAD:master
Queuing a new build and it will succeed to sync the test_fork repo using VSTS Git.
You can also configure schedules for this pipeline. Now everything is done.
If you use GitHub repo, please refer to this thread for guidance.

How to clone TFS to GitHub with history using Git-TFS?

I'm trying to clone a GIT repository in TFS using git-tfs using TFS 2012
git tfs clone http://sourcecontrol.oldcompanyname.local:8080/tfs/foo $/companyname/myrepository . --b=all --resumable
Gives me:
error: the path $/companyname/myrepository you want to clone doesn't exist!
I have an empty repository called /companyname/myrepository in my github account
(the urls and names are genericized for the public post)
Git TFS is for converting TFVC repositories to local Git repositories. It has nothing to do with GitHub. Once you have a local repo, you can add a GitHub remote and push it there.
The clone URL should be the path to your TFS instance, stopping at the project collection. http://companyname.local:8080/tfs/DefaultCollection.
The next part is the path to a folder in the TFVC repository. If you have a team project named Foo and you want to clone the Main branch, you'd specify $/Foo/Main.

How to sync repo in bitbucket to Visual studio team service?

I am very new to VSTS platform. In one of my project, I am trying to integrate the bitbucket source control to VSTS. By this way I should be able to see the updates made on bitbucket onto the VSTS account.
I have tried creating build on VSTS, but that only shows the commits history of the selected repository of bitbucket.
Is there a way to manage all the bitbucket changes on VSTS as source control?
To sync changes from bitbucket repo to VSTS git repo automatically, you can achieve it by using a VSTS build definition. Detail steps as below:
1. Create a build definition with Bitbucket repo
When creating a VSTS build definition -> Select the Bitbucket repo you want to sync -> create.
2. Enable continuous integration
In the build definition -> Triggers Tab -> Enable continuous integration -> Include all branches with *.
3. Add PowerShell task with the script to sync bitbucket repo with VSTS git repo
Add a PowerShell task with below script:
if ( $(git remote) -contains 'vsts' )
{git remote rm vsts
echo 'remove remote vsts'
}
$branch="$(Build.SourceBranch)".replace("refs/heads/","")
git remote add vsts https://Personal%20Access%20Token:PAT#account.visualstudio.com/project/_git/repo
git checkout $branch
git push vsts $branch -f
For the detail steps to add and config the PowerShell task as below:
Edit your build definition -> Click + to add a task for your agent phase -> Search powershell task -> click Add -> click the PowerShell task you added -> select Inline type -> then add your powershell script in the Script option -> Save build definition.
Now no matter which branch is updated in your bitbucket repo, VSTS git repo will be synced automatically.
Yo sync changes from VSTS git repo to bitbucket repo, you can create another CI build to achieve it. Detail steps as below:
1. Create a CI build with VSTS git repo
2. Enable continuous integration
3. Add a PowerShell task with below aspects
if ( $(git remote) -contains 'bitbucket' )
{git remote rm bitbucket
echo 'remove remote bitbucket'
}
git remote add bitbucket https://username:password#bitbucket.org/username/repo.git
$branch="$(Build.SourceBranch)".replace("refs/heads/","")
git checkout $branch
git push bitbucket $branch -f
When you connect your Bitbucket account to VSTS, you are setting up build triggers to run automated builds on pull requests or merges. This is what is called "continuous integration" in the DevOps world.
Consider reading the documentation for more information on this topic.
You will continue to "manage" your Bitbucket repos on Bitbucket. It's totally separate. If you want to manage everything through VSTS, you should import your Bitbucket repo to your VSTS account.

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.