<p>People may or may not know, but this site runs on <ahref="https://sculpin.io/">Sculpin</a>, a PHP based static site generator (this may be the first time that I've mentioned it on this site). The source code is hosted on <ahref="https://github.com/opdavies/oliverdavies.uk">GitHub</a>, and I've listed the site on the <ahref="https://sculpin.io/community/">Community page</a> on the Sculpin website.</p>
<p>To get it there, I forked the <ahref="https://github.com/sculpin/sculpin.io">main sculpin.io repository</a> so that I had <ahref="https://github.com/opdavies/sculpin.io">my own copy</a>, created a branch, made my additions and submitted a pull request. Easy enough!</p>
<h2id="new-domain">New Domain</h2>
<p>In the last week or so, I've changed this site URL from .co.uk to just .uk, and also updated the GitHub repo URL to match, so I wanted to update the Community page to use the correct URL.</p>
<p>There had been commits to the main repo since my pull request was merged, I didn't want to delete my repo and fork again, and making any changes against and old codebase isn't best practice, so I wanted to merge the latest changes into my forked repo before I did anything else - just to check that I didn't break anything!</p>
<h2id="updating-my-local-repo">Updating my Local Repo</h2>
<p>I had a quick look for a <em>Update my fork</em> button or something, but couldn't see one to I added the main repository as an additional remote called <code>upstream</code> and fetched the changes.</p>
<p>Now my local site knows about the upstream repo, and I could rebase the changes (<code>git pull upstream master</code> should have worked too) and push them back to origin.</p>
<pre><codeclass="language-bash">$ git rebase upstream/master
First, rewinding head to replay your work on top of it...
...
Fast-forwarded master to upstream/master.
$ git push origin master
</code></pre>
<p>This seems to have worked OK - the commits are still authored by the correct people and at the correct date and time - and I went ahead and created a new feature branch and pull request based on that master branch.</p>
<figure>
<imgsrc="/assets/images/blog/forked-github-repo-commits.png"alt="The commits on my master branch after rebasing">
<figcaption>The commits on my forked master branch after rebasing and pushing. All good!</figcaption>
</figure>
<figure>
<imgsrc="/assets/images/blog/my-commit-to-the-rebased-branch.png"alt="The new feature branch with my additional commit.">
<figcaption>The new feature branch with the new commit.</figcaption>
</figure>
<h2id="is-there-a-better-way%3F">Is There a Better Way?</h2>
<p>Did I miss something? Is there a recommended and/or better way to update your forked repos, maybe through the UI? Please <ahref="https://twitter.com/?status=Rebasing GitHub Forks: @opdavies">send me a tweet</a> with any comments.</p>
<h2id="update%3A-rebasing-in-phpstorm">Update: Rebasing in PhpStorm</h2>
<p><strong>December 2015:</strong> I’ve found that PhpStorm has an option available to rebase a fork from within the IDE. This is within the <em>VCS</em> > <em>Git</em> menu.</p>
<p>I believe that it will use an existing "upstream" remote if it exists, otherwise it will add one automatically for you, linking to the repository that you forked from.</p>
<p>Once you’ve completed the rebase, you can then push your updated branch either from the terminal, or using the <em>Push</em> command from the same menu.</p>
<p><imgsrc="/assets/images/blog/github-fork-rebase-phpstorm.png"alt="Rebasing a forked repository in PhpStorm using the VCS menu."/></p>
<p>It would be great to see something similar added to <ahref="https://hub.github.com">hub</a> too (I’ve created <ahref="https://github.com/github/hub/issues/1047">an issue</a>)!</p>
<h2id="resources">Resources</h2>
<ul>
<li><ahref="http://blog.jetbrains.com/idea/2011/02/advanced-github-integration-rebase-my-github-fork/">PhpStorm - Advanced GitHub Integration: Rebase My GitHub Fork (blog post)</a></li>
<li><ahref="https://www.youtube.com/watch?v=Twy-dhVgN4k">Rebasing a GitHub fork inside PhpStorm (video)</a></li>
<li><ahref="https://hub.github.com">hub</a> - makes Git better with GitHub</li>
<p>Oliver Davies is a Web Developer, System Administrator and Drupal specialist based in the UK. He is a Senior Developer at <ahref="https://microserve.io">Microserve</a> and also provides freelance consultancy services for Drupal websites, PHP applications and Linux servers.</p>
</div>
</main>
<divclass="col-md-3">
<divclass="panel badges text-center">
<aclass="badge--da-member"href="https://assoc.drupal.org/membership"title="I’m a Drupal Association member.">