# Using Pkg, how do I dev a local branch of a package

**URL:** <https://discourse.julialang.org/t/using-pkg-how-do-i-dev-a-local-branch-of-a-package/127069>\
**Category:** Package Management\
**Created:** [March 17, 2025, 7:50pm UTC](https://discourse.julialang.org/t/using-pkg-how-do-i-dev-a-local-branch-of-a-package/127069 "2025-03-17T19:50:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [March 17, 2025, 7:50pm UTC](https://discourse.julialang.org/t/using-pkg-how-do-i-dev-a-local-branch-of-a-package/127069/1 "2025-03-17T19:50:29Z")

</div>

There is a package that I am developing ([GitHub - SciML/Catalyst.jl: Chemical reaction network and systems biology interface for scientific machine learning (SciML). High performance, GPU-parallelized, and O(1) solvers in open source software.](https://github.com/SciML/Catalyst.jl)). Locally, I have a couple of branches of it. I also have an environment where I would like to use a specific of these branches (one which is not pushed onto GitHub). is there a way to do this?

Previously I just did

```julia
]dev Catalyst

```

however, that gives me the active branch. If I am working with two branches in parallel (one which I want to use for this project, and one where I am preparing a new PR) this is not possible using this approach.

---

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [March 17, 2025, 8:43pm UTC](https://discourse.julialang.org/t/using-pkg-how-do-i-dev-a-local-branch-of-a-package/127069/2 "2025-03-17T20:43:59Z")

</div>

The `dev` command should give you the current code in the directory and no matter whether it is committed to `git` or not. You can still access the code in other branches by using `add` with the full path to the repository and appending `#branchname` on the end of the path even if the branch is not the current HEAD, e.g. :

```plaintext
] add ~/code/MyPackage.jl#devbranch2

```

If this is not enough, then you could either clone your local working copy or make a recursive copy of it (in Linux this is done with `cp -a`). But only do this if you have to, as it can get quite confusing to be working on two copies of the same code.

---

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [March 17, 2025, 9:10pm UTC](https://discourse.julialang.org/t/using-pkg-how-do-i-dev-a-local-branch-of-a-package/127069/3 "2025-03-17T21:10:12Z")

</div>

> [@GHTaarn](#):
>
> `] add ~/code/MyPackage.jl#devbranch2`

This will perform a local git pull to obtain the code from the repo `~/code/MyPackage.jl`. The code changes in the latter folder will not be automatically tracked. Any changes need to be committed first, and then in the virtual environment where you ran `Pkg.add`, you need to run `Pkg.update` to obtain the new code. If instead, you want to automatically track code changes in `~/code/MyPackage.jl`, including any committed or uncommitted changes (or even without a git repo in the folder at all), you need to run

```julia
] dev ~/code/MyPackage.jl

```

---

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [March 18, 2025, 10:53am UTC](https://discourse.julialang.org/t/using-pkg-how-do-i-dev-a-local-branch-of-a-package/127069/4 "2025-03-18T10:53:21Z")

</div>

So if I want to get branch `required_branch` of package Catalyst, I should do

```julia
] add .../.julia/dev/Catalyst#required_branch

```

And then I can switch to another active Catalyst branch, but `required_branch` should be preserved for that environment? Next, version of

```julia
]dev Catalyst

```

will only ever give me there currently active code in “…/.julia/dev/Catalyst”, whether it is committed or not?

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [March 18, 2025, 12:04pm UTC](https://discourse.julialang.org/t/using-pkg-how-do-i-dev-a-local-branch-of-a-package/127069/5 "2025-03-18T12:04:31Z")

</div>

`dev` is not git-aware like `add` is, it simply uses whatever code is in the local folder. So if you want to dev two different branches, you’ll need to make two separate clones of the repo into different folders, check out the branches you want to dev in each one, then do

```julia
pkg> dev /path/to/repo

```

---

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [March 18, 2025, 12:10pm UTC](https://discourse.julialang.org/t/using-pkg-how-do-i-dev-a-local-branch-of-a-package/127069/6 "2025-03-18T12:10:29Z")

</div>

Thanks guys, this was really helpful. Think I understand how to (and not how to) do it now!

---

<div class="post-metadata">

**Author:** ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Post date:** [March 18, 2025, 5:17pm UTC](https://discourse.julialang.org/t/using-pkg-how-do-i-dev-a-local-branch-of-a-package/127069/7 "2025-03-18T17:17:00Z")

</div>

> [@cjdoris](#):
>
> So if you want to dev two different branches, you’ll need to make two separate clones of the repo into different folders

I haven’t used the worktree feature myself, but this sounds like a good usecase for [git worktree](https://git-scm.com/docs/git-worktree)s.
