This post will describe how to sync a project between GitHub and Visual Studio Online (VSO). Visual Studio Online provides a set of cloud-powered collaboration tools that work with your existing IDE or editor, so your team can work effectively on software projects of all shapes and sizes. To implement synchronisation, we used Git remote, which will enable to connect to a remote repo and then pull from it and push to the other repo. Remote repositories are versions of your project that are hosted on the Internet or network somewhere. You can have several of them, each of which generally is either read-only or read/write for you. Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work. Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote branches and define them as being tracked or not, and more.
Step 1: Enabling Alternate Authentication Credentials for VSO Account
1. In Visual Studio Online, navigate to your Account’s Security tab.
2. You will see the list of all options, from which choose Alternate authentication credentials, which will allow access for other applications outside the browser.
3. Mark the checkbox to Enable alternate authentication credentials.
Step 2: Adding remote repo
To see which remote servers you have configured, you can run the <git remote> command. It lists the short names of each remote handle you’ve specified. To add remote repo, you will need to open your local repo with Visual Studio 2015, which is connected to your VSO.
1. Open the command line to that local repo and type: <git remote add github https://github.com/Codeflyers/EC-GitHub>
2. Select the local branch by double click (not from remotes) and make sure it’s bold.
3. You can also use the command line instead of Visual Studio, just type <git checkout> and type the needed branch. If you will look at the Visual Studio, you will notice that it’s also bold.
Step 3: Pull from the needed branch and Push to the Visual Studio Online
Use the <git pull> command to automatically fetch and then merge that remote branch into your current branch. This is usually used when your current branch is set up to track a remote branch.
1. Type command <git pull github dev>.
2. Now when the project is at a point that you want to share it, you have to push it upstream. Type command: <git push origin dev>.
When you push to a remote repository, you do not have to push all of your branches. You can choose to share just one of your branches, a few of them, or all of them. This option is very good for trying new ideas without worrying about having to plan how and when they are going to merge it in or share it with others. In our case, we will do that with each branch and to remove the remote repo by type, we will use the command <git remote remove github>. In addition, we will keep the remote repo to sync later. There is also the possibility remote repo to VSO by type: <git remote add vsonline https://codeflyers.visualstudio.com/DefaultCollection/_git/EC-VSO/>.