Making a pull request for a Julia package

Jan 12, 2022 · 320 words · 2 minute read

I just wanted to document my workflow for making a pull request to a Julia package. Let us say that there’s a package called MyPackage located on GitHub, which you have already installed in local Julia installation.

First, from the Julia REPL, we run

    julia> using Revise
    pkg> develop MyPackage

This clones the MyPackage git repo to the location ./julia/dev/MyPackage and activates this version.

In principle, you can now go ahead and play with this package and make commits. However, we’d like to be a bit more systematic. Let’s say you would like to contribute an awesome new feature to this package. First, we fork the repo on GitHub to hershsingh/MyPackage, by just clicking Fork at the top-right corner of the original repository in the GitHub web interface.

Now, we can add the forked repo as a remote on our local repo at ./julia/dev/MyPackage. This will allow us to push changes this this forked repo. Navigate to the local repo for this package from terminal and run:

$ cd .julia/dev/MyPackage
$ git remote -v

At this point, running git remote -v will only show the origin for package, which is the main repo for this package. We can add our forked repo as a new remote:

 $ git remote add myfork
 $ git remote -v

Now, you should see both origin and myfork in the output of git remote -v.

Once you have added the remote, then you can go ahead and make the changes to your package. Create a new branch, say awesome-feature, and commit a bunch of changes to it. Now we can push this new branch into the remote.

$ git push myfork awesome-feature

Once you have pushed the changes to the remote repo, you can go ahead and create a pull request on GitHub. Usually, GitHub will automatically detect that you pushed a new branch and offer you to create a pull request. That’s it!