Working with GitHub Fork in Visual Studio
GitHub is a great place for open source project that you can contribute to. One of them is the Firefly-doc repository which has all the developers documentation. This article explain how to work with a repository that you have only read access using Visual Studio.
Create a Fork on GitHub
If you don't already have a fork of the repository you can create one.
- Open a web browser to the GitHub project page (i.e. https://github.com/FireflyMigration/firefly-doc).
- Make sure you have a GitHub account and that you are logged in (your user avatar should appear at the top right corner)
- Click on the "Fork" button in the upper right corner.
This creates a copy of the repository under your GitHub account which you have read and write access.
Clone the forked repository
Clone your forked repository to your local machine using Visual Studio.
This creates a local clone of your repository with the cloud repository is configured as the default remote named "origin"
Notice that this is your own copy of the repository connected to the fork and not the main repository.
Keeping your fork up to date with the main repository
Create "upstream" remote
First, you need to add a second remote that refer to the original master repository.
- Click on View -> Team Explorer
- Click on the Home button
- Click on Settings
- Click on "Repository Settings" hyper-link
- Under "Remotes" sub-menu, click "Add" hyper-link
- Enter "upstream" in the name and the main repository url (i.e. https://github.com/FireflyMigration/firefly-doc) in Fetch
- Click Save
This create a connection to the main repository named "upstream" that will allow us to get the latest change from it.
Pulling updates from the main (upstream) repository
Sooner or later, the main repo will have updates that you will want to pull into your fork.
If you go to your fork's GitHub web page you will see that there is a line just before the description of the files in the repo that indicates if your fork is ahead, behind or in sync with the master branch of the original repo.
To pull the latest changes and bring your fork up date:
- Click View-> Team Explorer
- Click on the Home button
- Click on Sync
- Click on Fetch
- In the combo-box select upstream
- Click on the Fetch button
This will fetch all the changes from the "upstream" repository and put them in the LOCAL repository.
Notice that this does not change any existing branch.
Merging the changes from upstram/master branch into the local master branch
- Click View-> Team Explorer
- Click on the Home button
- Click on Branches
- Make sure that master is the active branch (it should be bold). If not double click on master to make it the active branch. You may have to commit all the current changes before you can switch branches.
- Right click the master branch and select "Merge from..."
- Select upstream/master in "Merge from branch:"combo-box
- Click Merge
Pushing the local repository to your GitHub fork
- Click on View-> Team Explorer
- Click on the Home button
- Click Sync
- Click on the "Push" hyper-link
- Select "origin" in the first combo-box
- Select "master" in the second combo-box
- Click Push
Go to your GitHub web page for the fork and make sure that you see a line that says:
"This branch is even with FireflyMigration:master."
Contributing to the main repository using Pull Request
Creating a pull request to the main repository starts by creating a local branch for your work and pushing this branch to your GitHub fork.
At this point you should already be up-to-date with the main repository.
Create a local branch
- Click on View -> Team Explorer
- Click on the Home button
- Click on Branches
- Right click on master and select "New Local Branch From..."
- Enter a branch name
- Select "master" in the combo-box
- Click on Create Branch button
Publish the branch
Once your work is done and committed to your local new branch you need to push it to the GitHub fork
- Click on View -> Team Explorer
- Click on the Home button
- Click on Branches
- Right click your new branch and select "Publish Branch"
This creates a new branch in your GitHub Fork that is tracked by the local branch with the same name.
Create a pull request
- Go to your fork page on GitHub website
- Near the top left side, change the active branch to your new branch
- Click on the "New Pull Request" button next to the branch name.
- Enter a description and submit
Create a pull request by Visual Studio
- Click on View -> Other Window -> Github
- Click on Create New
- Select FireflyMigration:master < Name of the new branch
- Click on Create pull request button
Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com