# Merging a long-active development branch of a package

**URL:** <https://discourse.julialang.org/t/merging-a-long-active-development-branch-of-a-package/25730>\
**Category:** Internals & Design\
**Tags:** statistics\
**Created:** [June 26, 2019, 4:21pm UTC](https://discourse.julialang.org/t/merging-a-long-active-development-branch-of-a-package/25730 "2019-06-26T16:21:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [June 26, 2019, 4:21pm UTC](https://discourse.julialang.org/t/merging-a-long-active-development-branch-of-a-package/25730/1 "2019-06-26T16:21:33Z")

</div>

Those who follow the `JuliaStats` world will be aware that a major upgrade of `StatsModels` just landed as v"0.6.0", aka “Terms 2.0”. Thanks to @dave.f.kleinschmidt for leading the development on this.

I have a “terms2.0” branch in the `MixedModels` package repository that uses this new formulation, which I would like to incorporate into the “master” branch. The development branch is about 150 commits ahead and 20 commits behind master.

What is a good strategy to merge such a development branch into the master branch?

Should I try to rebase terms2.0 on master first? Some things get a bit tricky there because both branches switched from REQUIRE to Project.toml so there are commits that change a REQUIRE file that is no longer part of the project.

I know that at some point I want to collapse all the changes in the terms2.0 branch to a single commit on the master branch, as @dave.f.kleinschmidt did in `StatsModels`. I just not sure exactly when that is done.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [June 26, 2019, 4:46pm UTC](https://discourse.julialang.org/t/merging-a-long-active-development-branch-of-a-package/25730/2 "2019-06-26T16:46:25Z")

</div>

Rebases like this can get annoying pretty quickly. There are tools that can make it easier but if you’re going to produce a single commit in the end it’s probably not worth the pain. The easiest way to get that commit is to merge master into your branch and then when everything is in the state you want to end up in, just take that working tree and make a commit out of it on top of master. One way to do this is from the tree you want to commit, check out master without checking out the files (I forget the invocation), then just make the commit. This is way easier than screwing around with rebasing in my experience.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [June 26, 2019, 4:52pm UTC](https://discourse.julialang.org/t/merging-a-long-active-development-branch-of-a-package/25730/3 "2019-06-26T16:52:05Z")

</div>

Another way to do it is to get in the state you want things in with whatever history, do `git diff master > patch.diff` to save the diff from master to a file, then check out master and do `git apply < patch.diff` To apply that diff on top of master. Poof, history gone!

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [June 26, 2019, 5:00pm UTC](https://discourse.julialang.org/t/merging-a-long-active-development-branch-of-a-package/25730/4 "2019-06-26T17:00:38Z")

</div>

Then when you commit it, you may want to change the lead author and/or add co-authors to respect the authorship of the branch. You can change the lead author with the [`--author` git switch](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---authorltauthorgt), and you can add co-authors by putting [`Co-authored-by: ...` lines](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---authorltauthorgt) at the bottom of your commit message.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [June 26, 2019, 5:05pm UTC](https://discourse.julialang.org/t/merging-a-long-active-development-branch-of-a-package/25730/5 "2019-06-26T17:05:46Z")

</div>

While you _can_ do the manual process suggested above, I wouldn’t recommend it. Instead, you can just ask github to do the work of taking your branch and converting it into a single commit onto master by doing a squash-merge, which is available any time a github pull request is merged (see [About pull request merges - GitHub Docs](https://help.github.com/en/articles/about-pull-request-merges#squash-and-merge-your-pull-request-commits) ).

My recommendation would be:

1. Merge master into your branch on your machine
2. Push your updated branch
3. When your PR is ready to go, make sure whoever merges it uses the “squash and merge” option.

No rebasing or manual patch creation necessary 🙂

---

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [June 26, 2019, 6:49pm UTC](https://discourse.julialang.org/t/merging-a-long-active-development-branch-of-a-package/25730/6 "2019-06-26T18:49:50Z")

</div>

Thank you for the responses. I ended up using @rdeits suggestions and it worked smoothly, I think. Of course, past experience with git makes me cautious about any “it worked smoothly” claims.
