DEV Community

Oliver Pham
Oliver Pham

Posted on

Working with Remote Branches

This week on my Open Source journey, I attempted to add support for JSON formatted configuration files for an open source Static Site Generator (SSG). The owner of the repo, Tengzhen, also contributed the same feature to my SSG, Silkie. However, I made a step forward by testing his code from a tracking branch before merging it.

What I was working on

Like any time when I work on someone else's repo, I forked their original repo and made any changes on its clone. However, I decided to make a draft Pull Request (PR) this time so that Tengzhen can give me some feedback on my progress. Thanks to his clean and well-structured codebase, I managed to integrate the feature by adding a new flag and a small block of code. My PR finally got merged into his main branch.

Review & test the PR

As for Tengzhen, he also made a draft PR. To help him out with it, I "fetched" his remote branch (using git fetch) to my local machine and tested his code. Although it was a totally new concept for me, setting up a tracking branch was pretty straightforward.

I noticed a few bugs in Tengzhen's code, attempted to fix them, and commented about my recommendations on GitHub. He gladly modified his code and pushed the changes, which were finally merged into my main branch.

Conclusion

I have been wondering how I can test code on a remote branch before merging them. Setting up a CI/CD pipeline would be a complicated and time-consuming task, which is what I'm trying to avoid right now. Luckily, Git enables me to create a tracking branch in my local repo with ease and merge it once it's ready.

Top comments (0)