title: Git local alias and submodule foreach recursive
body: <p>I am trying to define git local alias which can perform git command on all the submodules,
  and it partly works but only for git commands or global alias. It seems that git submodule foreach --recursive does not read the .git/config,
  and of cause I added the alias to all the submodels (using the same command).</p>
  <p>The test has been performed on
  #lsb_release -a
  No LSB modules are available.
  Distributor ID: Ubuntu
  Description:    Ubuntu 20.04.3 LTS
  Release:        20.04
  Codename:       focal</p>
  <p><strong>uname -a</strong></p>
  <p>Linux spaceship 5.4.0-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux</p>
  <p><strong>git --version</strong></p>
  <p>git version 2.25.1</p>
  <p><strong>echo $SHELL</strong></p>
  <p>/usr/bin/tcsh</p>
  <p>I performed the following test.</p>
  <p>Create a test repo</p>
  <pre><code> mkdir git_config_test
   cd git_config_test
   git init
  Initialized empty Git repository in /tmp/git_config_test/.git/
  </code></pre>
  <pre><code> ls -al
  drwxrwxr-x  3 carsten carsten   4096 лис 27 15:13 .
  drwxrwxrwt 34 root    root    143360 лис 27 15:13 ..
  drwxrwxr-x  7 carsten carsten   4096 лис 27 15:13 .git
  
   echo &quot;#Git config test&quot; &gt; README.mk
   git add README.md 
   git commit -am&quot;First commit&quot;
   git log
  </code></pre>
  <p>Define a local alias</p>
  <pre><code> git config alias.fingerprint &quot;rev-parse HEAD&quot;
   git fingerprint
  9202796e70acb5d247b74da5eb4d007253e73a38
  </code></pre>
  <p>Create a new repo for the submodule</p>
  <pre><code> pwd
  /tmp/git_config_test
   cd ..
   mkdir git_config_test_submodule.git
   cd git_config_test_submodule.git
   git init
   echo &quot;#Git submodule&quot; &gt; README.md
   git add README.md
   git commit -am&quot;First submodule commit&quot;
  </code></pre>
  <p>Add the submodule to the module</p>
  <pre><code> cd ../git_config_test
   git submodule add ../git_config_test_submodule.git 
   git commit -am&quot;Submodule added&quot;
   ls -al
  total 160
  drwxrwxr-x  4 carsten carsten   4096 лис 27 15:18 .
  drwxrwxrwt 36 root    root    143360 лис 27 15:18 ..
  drwxrwxr-x  8 carsten carsten   4096 лис 27 15:18 .git
  -rw-rw-r--  1 carsten carsten     17 лис 27 15:14 README.md
  drwxrwxr-x  3 carsten carsten   4096 лис 27 15:18 
  </code></pre>
  <p>Now we added the alias to submodules also</p>
  <pre><code> git submodule foreach --recursive git config alias.fingerprint 'rev-parse HEAD'
  </code></pre>
  <p>Check that the alias.fingerprint still works</p>
  <pre><code> git fingerprint
  d381bc4ce0d42e9c3f8062be496f7cb6d266f1b9
  </code></pre>
  <p>Check that the alias.fingerprint works in the submodule.</p>
  <pre><code> cd git_config_test_submodule
   git fingerprint
  1c7ddc2d79d0d7e8314540b03b6589c0876ee9a2
  </code></pre>
  <p>Now we define an alias to perform submodule recursive in the main repo</p>
  <pre><code> pwd
  /tmp/git_config_test
   git config alias.all 'submodule foreach --recursive'
  </code></pre>
  <p>We can test that the alias works.</p>
  <pre><code> git all git rev-parse HEAD
  Entering 'git_config_test_submodule'
  1c7ddc2d79d0d7e8314540b03b6589c0876ee9a2
  </code></pre>
  <p>And we can check that the aliases have been defined for the main module.</p>
  <pre><code> git --no-pager config --local --get-regexp alias 
  alias.fingerprint rev-parse HEAD
  alias.all submodule foreach --recursive
  </code></pre>
  <p>And we can also check that the aliases have been defined for the submodules by using the newly defined alias.all</p>
  <pre><code> git all git --no-pager config --local --get-regexp alias
  Entering 'git_config_test_submodule'
  alias.fingerprint rev-parse HEAD
  </code></pre>
  <p>The <strong>problem</strong> is now, I would expect that alias.all would execute the aliases defined in the .git/config, but it seems that it doesn't see them for some reason.
  As can be seen in the following test.</p>
  <pre><code> git all git fingerprint
  Entering 'git_config_test_submodule'
  path='git_config_test_submodule'; fingerprint: 1: fingerprint: not found
  fatal: run_command returned non-zero status for git_config_test_submodule
  .
  </code></pre>
  <p>But it works if the alias has been defined in the ~/.gitconfig</p>
  <pre><code> git all git --no-pager config --get-regexp alias|grep hash
  alias.hash rev-parse HEAD
   git all git hash
  Entering 'git_config_test_submodule'
  1c7ddc2d79d0d7e8314540b03b6589c0876ee9a2
  </code></pre>
  <p>So I find this a little odd.</p>
  <p>If somebody would give me a hint to what I am doing run. I will be grateful.</p>