# Updating submodules

**URL:** <https://discourse.mc-stan.org/t/updating-submodules/352>\
**Category:** Developers\
**Created:** [April 20, 2017, 3:46am UTC](https://discourse.mc-stan.org/t/updating-submodules/352 "2017-04-20T03:46:32Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbbales2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bbbales2/32/77_2.png) [@bbbales2](https://discourse.mc-stan.org/u/bbbales2)\
**Post date:** [April 20, 2017, 3:46am UTC](https://discourse.mc-stan.org/t/updating-submodules/352/1 "2017-04-20T03:46:32Z")

</div>

I was going to make a follow up Stan commit from the Math commit here [https://github.com/stan-dev/math/pull/521](https://github.com/stan-dev/math/pull/521) (adding the Stan interface for the stuff)

Should I update the math submodule in the Stan repo with my pull request? It looks like the current submodule doesn’t quite point to the head of stan-dev/math (which will be required for the new code to build). When I pull down a fresh math submodule, it by default points to a few commits back [5a15e4, April 13th, seantalts].

If so, I assume I just check out the develop branch of the submodule and add it to the commit? (develop has the changes I need)

Just wanting to be clear. I’ve been confused by submodules before haha.

---

<div class="post-metadata">

**Author:** ![sakrejda](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sakrejda/32/845_2.png) [@sakrejda](https://discourse.mc-stan.org/u/sakrejda)\
**Post date:** [April 20, 2017, 1:05pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/2 "2017-04-20T13:05:31Z")

</div>

I’d say go ahead and update the submodule and get your work done. This is something that’s easy to change on a standing PR and it should not be holding you back from getting actual dev’ing done. I looked at our Dev process wiki and the exact procedure is not documented there. I’ve done a couple of these kinds of PR’s but I still don’t remember the exact procedure.

---

<div class="post-metadata">

**Author:** ![bbbales2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bbbales2/32/77_2.png) [@bbbales2](https://discourse.mc-stan.org/u/bbbales2)\
**Post date:** [April 20, 2017, 2:03pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/3 "2017-04-20T14:03:12Z")

</div>

Cool beans, yeah, that’s what I ended up doing. I didn’t even notice I had a bunch of submodule changes until I went to make the pull request :p (I have since cleaned them out).

---

<div class="post-metadata">

**Author:** ![sakrejda](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sakrejda/32/845_2.png) [@sakrejda](https://discourse.mc-stan.org/u/sakrejda)\
**Post date:** [April 20, 2017, 2:42pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/4 "2017-04-20T14:42:33Z")

</div>

One thing Stan has taught me is adding single files at a time to a commit!

---

<div class="post-metadata">

**Author:** ![bbbales2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bbbales2/32/77_2.png) [@bbbales2](https://discourse.mc-stan.org/u/bbbales2)\
**Post date:** [April 20, 2017, 3:14pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/5 "2017-04-20T15:14:15Z")

</div>

Hahaha, guilty. Gotta get off that commit -a :p.

---

<div class="post-metadata">

**Author:** ![seantalts](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/seantalts/32/32_2.png) [@seantalts](https://discourse.mc-stan.org/u/seantalts)\
**Post date:** [April 20, 2017, 3:53pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/6 "2017-04-20T15:53:57Z")

</div>

So you’re on `develop` and noticing that the `lib/stan_math` submodule is pointing to an older commit than current `develop` in the `math` repo, is that right? I’m still getting my head wrapped around the multi-repo idiosyncrasies here but I think there’s a Jenkins job that automatically creates pull requests to update the `math` submodule pointer I think whenever tests pass on `math`'s updated `develop` - creating something like this: [https://github.com/stan-dev/stan/pull/2282](https://github.com/stan-dev/stan/pull/2282) And then I think that’s where automation ends - I think at that point it might be up to someone with merge permissions to merge that pull request based on their judgement.

To slightly hijack this thread, this seems like an overly manual process - we only merge into `develop` when tests pass _on upstream as well_, so we probably don’t need a manual review of the pull request. I think it makes more sense to have the submodule track the head of the parallel branch in the repos downstream - `stan/develop` always pulls in the latest of `math/develop`, etc. Anyone have thoughts about that?

---

<div class="post-metadata">

**Author:** ![syclik](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/syclik/32/6_2.png) [@syclik](https://discourse.mc-stan.org/u/syclik)\
**Post date:** [April 20, 2017, 3:59pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/7 "2017-04-20T15:59:16Z")

</div>

We have a little bit of trouble with GitHub’s permissions. We currently  
have develop as a protected branch. There should be able to bypass the  
protection if we give Jenkins the right set of permissions.

---

<div class="post-metadata">

**Author:** ![bbbales2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bbbales2/32/77_2.png) [@bbbales2](https://discourse.mc-stan.org/u/bbbales2)\
**Post date:** [April 20, 2017, 4:12pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/8 "2017-04-20T16:12:18Z")

</div>

> > So you’re on develop and noticing that the lib/stan\_math submodule is pointing to an older commit than current develop in the math repo, is that right?

Yeah, exactly.

Oh! It looks like [Update submodule for the Stan Math Library by stan-buildbot · Pull Request #2282 · stan-dev/stan · GitHub](https://github.com/stan-dev/stan/pull/2282) has my stuff in it. So I’ll just wait until this goes through.

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [April 20, 2017, 7:16pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/9 "2017-04-20T19:16:13Z")

</div>

It’s through. We auto-spawn a pull request from lower level libraries to higher level libs on which they depend. We want to do all submodule updates this way. It’s fast, so usually not much lag at all.

Please don’t directly commit submodules.

---

<div class="post-metadata">

**Author:** ![bbbales2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bbbales2/32/77_2.png) [@bbbales2](https://discourse.mc-stan.org/u/bbbales2)\
**Post date:** [April 20, 2017, 7:17pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/10 "2017-04-20T19:17:44Z")

</div>

Yeah, I remembered you said not to do that before so I was pretty gun-shy. Thanks!

---

<div class="post-metadata">

**Author:** ![sakrejda](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sakrejda/32/845_2.png) [@sakrejda](https://discourse.mc-stan.org/u/sakrejda)\
**Post date:** [April 20, 2017, 7:21pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/11 "2017-04-20T19:21:55Z")

</div>

What’s wrong with messing up submodules on a branch? You can always fix it  
and squash before the PR is finalized.

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [April 21, 2017, 3:47pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/12 "2017-04-21T15:47:21Z")

</div>

I really meant don’t include them in pull requests.

Just a failure of imaginination on my part — when would you want to do that on purpose?

---

<div class="post-metadata">

**Author:** ![sakrejda](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sakrejda/32/845_2.png) [@sakrejda](https://discourse.mc-stan.org/u/sakrejda)\
**Post date:** [April 21, 2017, 4:01pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/13 "2017-04-21T16:01:17Z")

</div>

You want to update some stuff in Stan versus a different math but you don’t  
plan on finalizing a PR based on the work. I often muck around in a test  
repo without worrying about our dev process and then when I know I have  
stuff working I cleanly clone the repo I want to update in a separate  
directory and copy over the few files that are really going to change.  
Then I add/commit the files individually and follow dev process and deal  
with things like cpplint. Makes it easier to follow the strict dev process  
without having it slow me down. I’d never get anything done in Stan  
otherwise! K

---

<div class="post-metadata">

**Author:** ![seantalts](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/seantalts/32/32_2.png) [@seantalts](https://discourse.mc-stan.org/u/seantalts)\
**Post date:** [April 24, 2017, 7:47pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/14 "2017-04-24T19:47:26Z")

</div>

I’ve just added a bit of code that will hopefully auto-bump the math library from now on, though I need to double check that it works the next time someone merges into `develop`.

---

<div class="post-metadata">

**Author:** ![syclik](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/syclik/32/6_2.png) [@syclik](https://discourse.mc-stan.org/u/syclik)\
**Post date:** [April 24, 2017, 9:41pm UTC](https://discourse.mc-stan.org/t/updating-submodules/352/15 "2017-04-24T21:41:05Z")

</div>

Awesome!
