Github Fork & Pull Request Workflow

Workflow to raise Github Pull Request

Vikash Kumar

2 minute read

Github Fork & Pull Request Workflow

Many programmers use opensource code in there projects everyday. Many time it requires to add some feature or fix any bug and upstream the changes. There are many ways to achieve the same with the code hosted on Github. In this post, I am going to walk through one of the simple workflow.

If you are not familiar with Git, I will suggest to go through this tutorial.

Fork Github repositories to your own account

Login to your Github account and fork the repostiory to your account.

Clone the repository to your machine

git clone https://github.com/<Github User Name>/<Repo Name>.git

Add the upstream repository to the cloned repo

git remote add upstream <URL of remote github repo>

Verify the tracked repositories

git remote -v

Update your code with latest version of upstream repo

git fetch upstream

List the branches in your local code

git branch -va

Merge the fetched changes

git merge upstream/master

Create your feature branch

git checkout -b feature-branch

Commit changes and push the branch to your Github repo

git commit
git push origin feature-branch

Raise Pull Request to the original repo

Open the browser and log in to your Github account. Go to your repository. Navigate to feature branch. You should see a button for “New pull request”. Click the button, it will show the option to choose the branch of the remote repositories. If you did everything right, you will see all green which shows you can raise pull request safely. Otherwise, if there is conflict Github page will display hint in red (generally to rebase your branch)

Sync your branch (Optional)

git pull upstream master
git push origin master
git checkout feature-branch
git rebase master
git push origin feature-branch

Raise your pull request again.

Delete feature branch

git branch -d feature-branch
git push -d origin feature-branch
comments powered by Disqus