# 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.


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


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


GitHub Desktop will show that the merge was successful.


Finally push your branch with the merged changes to Github.


# 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.


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.


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.


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


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.


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


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!)