Welcome to another installment of TWIL, the weekly knowledge boost from Cuttlesoft where we showcase the practical insights our team members discover. In this week’s edition, Marisa offers a clear guide on how to Checkout Pull Requests from Forked Remotes in Git. Learn the step-by-step process to incorporate changes swiftly, even before they're merged upstream—perfect for times when updates can't wait.
Checkout pull request from forked remote
Say you have a library you are using, and there's an issue with it. A fix has been pull-requested, but it hasn't been merged in. We should:
- Fork the library
- Set the upstream
- Checkout the PR locally
- Push up our branch
- Set the source for the library as our forked branch
Fork the library for Cuttlesoft
git clone <cuttlesoft-library-url>
git remote add upstream <library-url>
git fetch upstream pull/<PR-ID>/head:<new-branch-name>
git checkout <new-branch-name>
git push origin <new-branch-name>
Get the url for the commit pushed up to our Cuttlesoft fork, it should look like:
https://github.com/cuttlesoft/<library-name>#<commit-hash>
Update your package.json
with the url like so:
"<library-name>": "https://github.com/cuttlesoft/<library-name>#<commit-hash>",
Make sure you yarn install
or npm i
and you should be good to go!
- Git