# Develop a local version of a registered package and submit changes as a pull request

**URL:** <https://discourse.julialang.org/t/develop-a-local-version-of-a-registered-package-and-submit-changes-as-a-pull-request/24868>\
**Category:** General Usage\
**Created:** [June 3, 2019, 12:43am UTC](https://discourse.julialang.org/t/develop-a-local-version-of-a-registered-package-and-submit-changes-as-a-pull-request/24868 "2019-06-03T00:43:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [June 3, 2019, 12:43am UTC](https://discourse.julialang.org/t/develop-a-local-version-of-a-registered-package-and-submit-changes-as-a-pull-request/24868/1 "2019-06-03T00:43:01Z")

</div>

I’ve been working through how one would go about making changes to a registered Julia package and submit the changes as a pull request. I haven’t found one source that explains the whole process, so I thought I’d share what I’ve come up with here. Let me know if anything seems wrong or if there are better ways to do this!

Also, I did find a nice [PR to the Pkg.jl repo](https://github.com/JuliaLang/Pkg.jl/pull/1145) that would add a lot of this to the Pkg docs, though the approach is slightly different from what I have below.

* * *

You can use the following procedure to make local changes to a registered Julia package and submit a pull request. The [Example.jl](https://github.com/JuliaLang/Example.jl) package is used as an example.

1. [Fork the package on GitHub](https://help.github.com/en/articles/fork-a-repo).

2. Clone your fork to a local directory of your choice:

```julia
$ git clone https://github.com/YOUR-USERNAME/Example.jl.git`.

```

Note that the origin for this repo is your forked repo:

```julia
$ git remote -v
origin	https://github.com/YOUR-USERNAME/Example.jl (fetch)
origin	https://github.com/YOUR-USERNAME/Example.jl (push)

```

1. Set the original GitHub repo as the _upstream_ repo:

```julia
$ git remote add upstream https://github.com/JuliaLang/Example.jl

```

Note that `upstream` is just a label for the URL of the original repo. Instead of calling it `upstream` you could call it something else like `original`. Now that we’ve added the `upstream` repo, our local repo is aware of two remote repos (`origin` and `upstream`):

```julia
$ git remote -v
origin	https://github.com/YOUR-USERNAME/Example.jl.git (fetch)
origin	https://github.com/YOUR-USERNAME/Example.jl.git (push)
upstream	https://github.com/JuliaLang/Example.jl (fetch)
upstream	https://github.com/JuliaLang/Example.jl (push)

```

1. Now you can keep your local repo in sync with the upstream repo by using `git pull`:

```julia
$ git pull upstream

```

1. In the Julia REPL package mode (entered by typing `]`), put your local repo into develop mode, which tells the package manager to track the directory containing your local repo:

```julia
(v1.1) pkg> develop /home/cbieganek/projects/Example.jl
 Resolving package versions...
  Updating `~/.julia/environments/v1.1/Project.toml`
  [7876af07] ↑ Example v0.5.1 ⇒ v0.5.1+ [`~/projects/Example.jl`]
  Updating `~/.julia/environments/v1.1/Manifest.toml`
  [7876af07] ↑ Example v0.5.1 ⇒ v0.5.1+ [`~/projects/Example.jl`]

```

We can see that the package manager is now tracking the directory containing our local repo:

```julia
(v1.1) pkg> status Example
    Status `~/.julia/environments/v1.1/Project.toml`
  [7876af07] Example v0.5.1+ [`~/projects/Example.jl`]

```

so if we do `using Example` in a Julia session, we will see any changes we’ve made to **Example.jl**.

1. Create a branch in your local repo and commit your changes to that branch, and then push your changes to your fork on GitHub.
2. Use GitHub to submit a pull request from your fork to the original repository.
3. If you wish, you can tell the package manager to return to using the registered version of **Example.jl** :

```julia
(v1.1) pkg> free Example
 Resolving package versions...
  Updating `~/.julia/environments/v1.1/Project.toml`
  [7876af07] ↓ Example v0.5.1+ [`~/projects/Example.jl`] ⇒ v0.5.1
  Updating `~/.julia/environments/v1.1/Manifest.toml`
  [7876af07] ↓ Example v0.5.1+ [`~/projects/Example.jl`] ⇒ v0.5.1

(v1.1) pkg> status Example
    Status `~/.julia/environments/v1.1/Project.toml`
  [7876af07] Example v0.5.1

```

So now the package manager is no longer tracking changes to the directory with your local repo.

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [April 30, 2020, 7:21pm UTC](https://discourse.julialang.org/t/develop-a-local-version-of-a-registered-package-and-submit-changes-as-a-pull-request/24868/2 "2020-04-30T19:21:42Z")

</div>

> [@CameronBieganek](#):
>
> Now you can keep your local repo in sync with the upstream repo by using `git pull` :

A clarification on Step 4:  
It seems that git will typically require you to designate which branch you are pulling from `upstream`. So, if you want to sync with the upstream master branch, you can do the following:

```julia
$ git checkout master # Checkout your local master branch
$ git pull upstream master # Pull contents of the upstream master branch

```
