Permalink
Fetching contributors…
Cannot retrieve contributors at this time
48 lines (37 sloc) 2.22 KB
---
title: Merging from Upstream Buildpacks
owner: Buildpacks
---
<strong><%= modified_date %></strong>
This topic describes how to maintain your forked buildpack by merging it with the upstream buildpack. This allows you to keep your fork updated with changes from the original buildpack, providing patches, updates, and new features.
The following procedure assumes that you are maintaining a custom buildpack that was forked from a Cloud Foundry system buildpack.
However, you can use the same procedure to update a buildpack forked from any upstream buildpack.
To sync your forked buildpack with an upstream Cloud Foundry buildpack:
1. Navigate to your forked repository on GitHub and click **Compare** in the upper right to display the **Comparing changes** page. This page shows the unmerged commits between your forked buildpack and the upstream buildpack.
1. Inspect the unmerged commits and confirm that you want to merge them all.
2. In a terminal window, navigate to the forked repository and set the upstream remote as the Cloud Foundry buildpack repository.
<pre class="terminal">
$ cd ~/workspace/ruby-buildpack
$ git remote add upstream git<span>@</span>github.com:cloudfoundry/ruby-buildpack.git
</pre>
1. Pull down the remote upstream changes.
<pre class="terminal">
$ git fetch upstream
</pre>
1. Merge the upstream changes into the intended branch. You may need to resolve merge conflicts. This example shows merging the `master` branch of the upstream buildpack into the `master` branch of the forked buildpack.
<pre class="terminal">
$ git checkout master
$ git merge upstream/master
</pre>
<p class="note"><strong>Note</strong>: When merging upstream buildpacks, do not use <code>git rebase</code>.
This approach is not sustainable because you confront the same merge conflicts repeatedly.</p>
1. Run the buildpack test suite to ensure that the upstream changes do not break anything.
<pre class="terminal">
$ BUNDLE\_GEMFILE=cf.Gemfile buildpack-build
</pre>
1. Push the updated branch.
<pre class="terminal">
$ git push
</pre>
Your forked buildpack is now synced with the upstream Cloud Foundry buildpack.
For more information about syncing forks, see the Github topic [Syncing a Fork](https://help.github.com/articles/syncing-a-fork/).