- Read Tutorial
Now that we're done with the Post
feature let's merge our code, which is currently on the add-posts
branch, with the application's master branch. Before we implement the feature let's look at a visual representation of what's happening when we're building features on a git branch. Below is a diagram that shows a similar flow to what we've done in this section.
The flow of the code commits are:
We took the master branch code and isolated a feature branch that we worked on and committed a number of changes to.
In the middle of our
post
feature build, a patch was required, we implemented the patch and merged that in with themaster
branch.Since we wanted to ensure that we were working with the latest version of the code we pulled the new version of master into the
post
feature branch.And now we're about to create a pull request and merge the
post
feature code into the master branch.
To do this let's go to the repo page on GitHub, and click on the Branches
link:
This page lists all of the branches for the application, click on the New Pull Request
button next to the feature branch for add-posts
:
This will take you to the page where you can open the new pull request and add a more detailed description of the work that you're wanting to merge into the branch. This stage becomes incredibly important when you're contributing to open source projects since other developers (who have no clue what you worked on) will need to review the code prior to merging it in.
Since you're the application owner you'll be able to merge the branch in by yourself. For an open source project your pull request would be sent to the owner for approval. This page shows you if there are any code conflicts. A potential conflict would be something such as: you and another developer worked on the same file and you didn't pull in their changes or vise versa, so git doesn't know what code the master
branch should use. When conflicts arise you'll need to bring down the merged code to your local system and fix the conflicts prior to pushing the code to the master
branch. However since we were good about merging the code into our feature branch it says that we don't have any conflicts so we can click the Merge Pull Request
button:
That's it! Our Post
feature is now merged in with the master branch, you can verify this by looking at the Latest Commit
column and see that it's now showing our latest changes. So nice work, that finishes up this section where we built the initial Post
feature.
In the next section we'll be switching gears and we'll begin to integrate the design.