1
votes

We have on-premises installed GIT. There we have our code repositories. Is it possible to connect a repository from this on-premises instance to Visual studio team services project?

So they display under "Code" bar?

vsts

I need it hosted on premises, but see code changes/commits and other GIT stuff in VSTS project

3

3 Answers

0
votes

No, it isn’t supported to display files or code of another repository under Code bar. You need to import that repository to the repository in VSTS. After that, you can push updates to VSTS repository if there are changes in your on-premises git repository. enter image description here

0
votes

You can't connect on premise GIT to VSTS. You may however use the VSTS rest APIs to push in code from your on premise GIT to VSTS. Typically you will setup a hook/trigger on your on premise GIT repo in order to automate the replication process.

0
votes

As others have said, you can have a "git hook", which is basically a git trigger to take action on some event. In this case, when code is pushed, to push it up to VSTS, but I assume you need to know the technical commands.

I had to do this the opposite way, and I did this quick and dirty. This pushes everything in one go, not each commit. This can also catch up a repo that is behind.

# Clone source repo (your local git repo)
git clone some_repo_path_goes_here
# I am skipping steps and assuming you are only syncing master branch.
# I have code to get all branches down before proceeding, but not posting it here.
# Assuming tags are on master branch..
# Get all tags
git fetch origin --tags

# Test to see if remote alias already exists
git ls-remote http://path_to_.visualstudio.com/org/project/_git/TargetRepoSameName
# Add a remote alias
git remote add any_name_123 http://path_to_.visualstudio.com/org/project/_git/TargetRepoSameName

# push local repo to 'any_name_123'
git push any_name_123 --all
# optional: delete all tags before attempting to push local tags
git push any_name_123 --delete `$(git tag -l)
# push local tags to remote repo 
git push any_name_123 --tags

You can schedule this job if you would like. I have a PowerShell job to do this with a lot more functions to do pull down the branches.