# git module always sets '--remote' for submodule updates

**URL:** <https://forum.ansible.com/t/git-module-always-sets-remote-for-submodule-updates/15722>\
**Category:** Ansible Project\
**Created:** [July 21, 2014, 9:41am UTC](https://forum.ansible.com/t/git-module-always-sets-remote-for-submodule-updates/15722 "2014-07-21T09:41:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michel\_Blanc](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@Michel\_Blanc](https://forum.ansible.com/u/Michel_Blanc)\
**Post date:** [July 21, 2014, 9:41am UTC](https://forum.ansible.com/t/git-module-always-sets-remote-for-submodule-updates/15722/1 "2014-07-21T09:41:55Z")

</div>

Hi,

I'm sending a probe here to see if I got this right before opening an issue.

When a git project is checked out using ansible, submodules are always  
updated with the '--remote' option.

[https://github.com/ansible/ansible/blob/devel/library/source\_control/git#L432](https://github.com/ansible/ansible/blob/devel/library/source_control/git#L432)

Here is the relevant piece of code :

if 'remote' in params:  
&nbsp;&nbsp;cmd = [ git\_path, 'submodule',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'update', '--init', '--recursive' ,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'--remote' ]  
else:  
&nbsp;&nbsp;cmd = [ git\_path, 'submodule',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'update', '--init', '--recursive' ]  
(rc, out, err) = module.run\_command(cmd, cwd=dest)

Note that the 'remote' in params is not related to the 'remote' git  
module option : tt is automatically gathered from possible 'git  
submodule' options (see  
[https://github.com/ansible/ansible/blob/devel/library/source\_control/git#L152](https://github.com/ansible/ansible/blob/devel/library/source_control/git#L152)).

The problem with this is that git will try to update the submodule to  
origin/master by default, and this is not always desirable (in my case,  
I don't even have a master branch).

As far as I know, there is not way to handle this righ now, besides  
setting branch.\<name\>.remote and submodule.\<name\>.branch in .gitmodules.

Can you confirm this is really an issue, or enlighten me otherwise ?

Thanks,

M

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 21, 2014, 12:33pm UTC](https://forum.ansible.com/t/git-module-always-sets-remote-for-submodule-updates/15722/2 "2014-07-21T12:33:50Z")

</div>

There are several tickets already open on the git module.

Bugfix submissions (pull requests) would be great, but I’d avoid opening up an extra ticket on the same subject.

[https://github.com/ansible/ansible/search?q=git&ref=cmdform&type=Issues](https://github.com/ansible/ansible/search?q=git&ref=cmdform&type=Issues)
