title: How to rename a git repo (project) which contains submodules in its subdirectories
body: <p>I never expect renaming a git repo, which, more specifically, is the top-level folder holds the project, would be so hard. Yes, the project containing some submodules, but it is the <strong>top-level folder</strong> that needs renaming, not the <strong>submodule folder</strong>. Git, it seems, records some odd <em>absolute paths</em> in its submodule mechanisms.</p>
  
  <p>Let's assume that</p>
  
  <ol>
  <li>All your projects locate in <code>/tmp</code>.</li>
  <li>You've got a <code>proj_master</code> and <code>proj_mod</code>.</li>
  <li>You clone <code>porj_master</code> as <code>proj_ALL</code> then clone <code>prom_mod</code> as a submodule in it.</li>
  <li>You rename <code>proj_ALL</code> to <code>proj_onebillion</code>. Then black magic happens.</li>
  </ol>
  
  <p>The following steps will reproduce the problem I mentioned. The version of git I use is:</p>
  
  <pre><code>$ git --version
  git version 1.7.9.5
  </code></pre>
  
  <hr>
  
  <ol>
  <li><p>Initialize <code>proj_master</code>.</p>
  
  <pre><code>$ cd /tmp
  $ mkdir proj_master; cd proj_master
  $ git init .
  $ touch README
  $ git add .; git commit -m "hello proj_master"
  </code></pre></li>
  <li><p>Initialize <code>proj_mod</code>.</p>
  
  <pre><code>$ cd /tmp
  $ mkdir proj_mod; cd proj_mod
  $ git init .
  $ touch README
  $ git add .; git commit -m "hello proj_mod"
  </code></pre></li>
  <li><p>Clone <code>proj_master</code> as <code>proj_ALL</code> and clone <code>proj_mod</code> as a submodule.</p>
  
  <pre><code>$ cd /tmp
  $ git clone proj_master proj_ALL
  $ cd proj_ALL
  $ git submodule add /tmp/proj_mod ./mod
  $ git add .; git commit -m "hello proj_ALL"
  $ git status   % Everything is OK.
  </code></pre></li>
  <li><p>Rename <code>proj_ALL</code> to <code>proj_onebillion</code>. Encounter a fatal error.</p>
  
  <pre><code>$ cd /tmp
  $ mv proj_ALL proj_onebillion
  $ cd proj_onebillion
  $ git status
  fatal: Not a git repository: /tmp/proj_ALL/.git/modules/mod
  </code></pre></li>
  </ol>
  
  <hr>
  
  <p>One thing to notice is the <code>.git</code> file in the submodule directory.</p>
  
  <pre><code>$ cat /tmp/proj_ALL/mod/.git 
  gitdir: /tmp/proj_ALL/.git/modules/mod
  </code></pre>
  
  <p>Yeah, an absolute path. For the first time, I realize that git is aware of something outside the scope of the top-level repo folder.</p>
  
  <p>That's it. I repeat that one more time that I rename the top-level project folder, not the submodule folder. I check <a href="https://stackoverflow.com/questions/9878860/how-can-i-rename-a-git-repository-with-submodules">schmuck's question</a>, which tried to rename the submodule folder, therefore seems not so helpful to my problem.</p>
  
  <p>If I miss something that should have been read before, I apologize. To all guys, any advice is welcomed. </p>