Merging

At this point you should have created a branch, made some code modifications, committed those changes, tested that they work (hopefully), and are now ready to bring those changes back into one of your main branches (ie Master or Development).

We call this process merging, and it is very simple, you can do it via the GitHub Desktop app or via the GitHub Pull Request interface online. I will show both methods below.

Merging with GitHub Desktop

Before you try to merge it is important to make sure you switch to branch to the branch you are wanting to merge into. (Not the branch you have been working on!) Select that branch in the GitHub Desktop app.

selectbase

Next, click on Branch at the top and then Merge into Current Branch

startmerge

Select the branch that you’ve been working off of that you want to merge from. Then hit the merge button.

selectbranch

GitHub Desktop will show that the merge was successful.

successfulmerge

Finally push your branch with the merged changes to GitHub.

push

Merging with GitHub Online

Alternatively you can use the GitHub online pull request interface to handle merging of branches. If you have branch protection setup, or if you want merges into your primary branches to require reviews then the above method using the desktop app won’t work. Furthermore, the pull request interface is what you use in order to bring official updates into your private repo and submit code you’ve written to contribute to the official repo should you ever chose to do so. Creating pull requests are super easy.

Start by going to GitHub.com and browsing to your personal Intersect repo. Click on the Pull Requests tab and then the New Pull Request button.

repo

We are merging code within our own repos right now so now make sure the base repository and head repository dropdowns point to your repo.

selectbase

See the arrow? That means the selection on the right will be merged into the selection on the left. We want to merge the branch we were working on back into the original branch we started with. I am merging my cleaning-up branch back into development.

selectbranches

Once the repos and branches are selected GitHub should tell you that you are able to merge and you can create the pull request.

createpr

GitHub will take you to one final screen where you can provide a title and description for your pull request. Once ready you can hit the Create Pull Request button one last time.

submitpr

With the pull request opened you can finally click the Merge pull request button to merge your code.

merge

Once the merge is complete you can finally return to the GitHub Desktop app, select your base branch, and pull the changes from GitHub. (You might have to fetch first!)

pull