• info@happli.be

Tag Archive git

Move an existing Git Repository to Visual Studio Team Services

Say you’ve been working on a project for a while. That project is not an open-source project. The source code is private and owned by your customer. You’ve been working alone so far, thus having a Git Repository hosted on a NAS and exposed through some VPN or WebDAV way (http://happliblog.azurewebsites.net/2015/09/07/setup-git-on-synology/) used to work a threat.

But someone joins the project. You have to give him access to the project’s source code, but you don’t want him to reach your NAS (additional trafic, security risks…). So you think about moving your repository to an online hosting. Several options exist out there. I considered two of them: GitHub and Visual Studio Team Services.

This post describes the platform I choose and how I “uploaded” my repository to the chosen hosting service. It then show how to add a team member using the selected platform.

GitHub vs VS Team Services

Pricing

Neither solution are free.

GitHub has a free offer for public repositories. But this isn’t an option if your code must remain private. Paying for the private repositories will cost you 7$/month.

GitHub pricing Details

GitHub pricing Details (https://github.com/pricing/plans)

Visual Studio Team Services (VSTS) is free for up to 5 users. Repositories are private.

Visual Studio Team Services pricing details

Visual Studio Team Services pricing details (https://www.visualstudio.com/pricing/visual-studio-team-services-pricing-vs)

As long as your team remains small (max 5 team members), Visual Studio Team Services is your best bet on the price side of things.

Features

Besides Git-base source code hosting, both platforms come with additional features. Here’s a subset of them. I’m not including advanced features like API

GitHUB has (https://github.com/features):

  • Issues tracking, with a nice commit-to-issue linking system
  • Pull requests: a kind of advanced collaborative mechanism. After collaborators have worked on a branch, when they want their changes to be integrated into the product’s main branch, they fill a pull request which contains code, comments and issues. It allows grouping information about a set of changes.
  • API (https://developer.github.com/v3/)
  • Syntax highlighting when browsing code in web views
  • Integrated Web Pages for blogging about a project… (https://pages.github.com/)

VSTS has (https://www.visualstudio.com/en-us/products/visual-studio-team-services-feature-matrix-vs.aspx):

Conclusion

Given that we’re only two team members working on the code  and I want to keep a private repository, Visual Studio Team Services wins on the pricing side of things.

On the feature side of things, Visual Studio Team Services offers a nice agile development process support. On the other hand, GitHub has a cool web pages offer. But the integrated CI feature of Visual Studio Team Services makes it my preference (less time spent configuring a CI system).

This project doesn’t involve a large organization nor specific integration with external tools. So I didn’t care about team management features nor about API’s exposed by the platforms.

So I went for Visual Studio Team Services.

Moving the existing repository to the hosted repository

Git and its ease of adding remote repositories allows for a smooth transition from a private repository to a more robust hosted one. In that way, it helps support scaling of the project.

Start by making sure you’ve got a clone of your existing repository on your local machine.

Given an existing Visual Studio Team Services account, create a project from that account (select Git as the versioning system). Then, navigate to the “code” tab of your project (see below).

VSTS Code Tab

VSTS Code Tab

You’ll get something like below. Start by generating Git Credentials (click on the button highlighted).

Generate Git Credentials

VSTS Generate Git Credentials

Once the credentials are generated, scroll down and you’ll find out how to push an existing Git repository to the VSTS hosted Git repository, as illustrated below.

Push Existing Repository To Another One

Push Existing Repository To Another One

Using your command line, navigate to the Git Repository that you’d like to “publish” to Visual Studio Team Services. Then execute the two commands above. Pay attention:

  • You might want to change “Origin” to some other name (if your local repository is a clone of another origin).
  • Don’t forget to change the URL in order to match your new repository’s name (in the screenshot above, the repository name is “test”).
  • You will need to specify the Git Credentials you’ve just created.

Git will do its job and push all the source code (including all branches) to Visual Studio Team Services. Go back to your browser and you should see the code. I didn’t even have to refresh the webpage!

Next step: adding the new contributor to the list of team members on VSTS.

Adding the new contributor

Adding the new contributor to the project is done on the project’s home page. Simply click on the “Team Members” panel (highlighted below) and then specify the new member’s e-mail address.

VSTS Project Team Members

VSTS Project Team Members

Setup Git on Synology through webdav

Suppose you want to use git for one of your projects. Suppose you don’t want to open your sources to everyone. You could resort to GitHub and get a private repository, but you’d have to pay for it and you want to limit the expenses.

If you own a NAS, then you might want to host your sources on it. I own a Synology Diskstation and I was able to host git repositories on it, working through Http (ssh was not an option because of non-configurable firewalls between me and my NAS in some scenarios). It’s using WebDav and works a threat.

Here are some of the tasks you’ll need to go through:

  • Add the Git package to your DiskStation (an official package exists)
  • Configure WebDav on your DiskStation
  • Open ports (to allow webdav in)
  • Setup your DiskStation with an SSL certificate (don’t want everyone on the wire see what you’re working on)
  • Configure DDNS on your DiskStation (so that you can use a DNS instead of your probably dynamic IP in order to reach your repositories)

The following tutorial has been of great help and I strongly recommend it:

http://blog.osdev.org/git/2014/02/13/using-git-on-a-synology-nas.html

Don’t forget the part related to post-update!!!

I found myself in troubles in the opening ports part, so I keep a copy of my findings here. Maybe it’ll help you as well!

Opening Ports => Beware of CGN and double NATs

Opening ports requires going to your router’s setup and adding rules to the port forwarding. I faced a problem with this: Even though everything seemed correctly configured, I couldn’t reach my repositories.

I was able to connect to the DiskStation remotely, using QuickConnect. So I thought that I could use QuickConnect and simply suffix the hostname (XXXXX.quickconnect.to) with the port number. It didn’t work. QuickConnect is designed to work with only a few applications, not including WebDav. So I had to use a DDNS.

After setting that DDNS up and making it look good (normal state in Diskstation DDNS management view), I added port forwarding rules to my router. And then I tested => didn’t work.

 

I have searched for hours and suspected something wrong with port forwarding. But I was able to connect to the DiskStation through QuickConnect. I couldn’t understand why the port forwarding that I had configured for Diskstation remote access (through QuickConnect) was working and that the one I was trying to configure for webdav (through DDNS) wasn’t. The answer wasn’t so obvious: connecting to DiskStation through QuickConnect doesn’t require ports forwarding (http://blog.synology.com/?p=2283), that’s simply not the way it works. I thought that ports forwarding was working, and it never had worked. I had defined useless port forwarding rules. Shame on me.

After browsing the web for a while, I discovered that I was in a double-NAT configuration (http://www.practicallynetworked.com/networking/fixing_double_nat.htm). My ISP, Voo, a Belgian ISP, seems to be putting the low contracts under a double NAT situation, through the use of a Carrier-grade NAT (CGN). Maybe they’re running out of IP Addresses.

No luck at the first phone call. Maybe the operator didn’t understand my request, maybe he didn’t wan’t to help, maybe he had received orders (trying to limit CGN related operations). I don’t know. I gave a second phone call later in the day and the operator did something that allowed me to get a public IP. No more double NAT => webdav working!!!

 

SSL Certificate

You can configure your diskstation with a self-signed one, but you’ ll need to install the CA on the different machines on which you’ll want to clone the repository.

If you don’t want/can’t install the CA, the following post shows how to trust temporarilly the self-signed certificate when cloning the repository : http://blog.decayingcode.com/post/temporarily-ignore-ssl-certificate-problem-in-git-under-windows