Reputation: 13
I would like to know is there any way we can sync the Git repository with the Git Integrated with VSTS. For example, say I have a Git repository "https://github.com/test/TestProject" and I have imported this Git repo in VSTS. Now my VSTS Git repository URL say "https://testuser.visualstudio.com/test/_git/TestProject".
I want to sync these two things and keep always updated. Like If I'm making any changes in the direct Git repo, it should reflect in the VSTS Git repository. Even if it's through any build definitions or any pull request, its fine.
Can someone help me in this?
Upvotes: 1
Views: 977
Reputation: 29966
It could be also achieved by creating a build definition to pull the changes from GitHub and then push the changes to VSTS Git. Following are the steps for your reference:
Now you should see a build been triggered when you commit a change in GitHub and then build will pull the changes from GitHub and push it to VSTS Git.
PowerShell code for your reference:
git remote add vstsg ssh://[email protected]:22/VSTSProjectName/_git/VSTSGitRepoName 2>&1 | Write-Host
git checkout -b master 2>&1 | Write-Host
git push vstsg master 2>&1 | Write-Host
Upvotes: 1
Reputation: 1324228
You need to have a webhook (ion GitHub) or a service hook (on Visual Studio) in order to receive a push event.
You also need to write and install a listener which would listen for that push event as sent by the web/service hook as a JSON payload (See the GitHub one, or the Visual Studio one).
Visual Studio integrates with external services as well, which have their own listener.
On receiving the push event from one remote repo, you can then pull from it, and push to the other. But note that any concurrent development on the same branch would potentially result in a conflict when pushing from one repo to the other. This approach works when differents branches are used on each repo.
Upvotes: 0