title: git: a quick command to go to root of the working tree
body: <p>I wanted a simple git command to go up to the "root" of the repository.</p>
  
  <p>I started with a script, but figured that I cannot change active directory of the shell, I had to do a function. Unfortunately, I cannot call it directly with the non-dash form "git root", for instance.</p>
  
  <pre><code>function git-root() {
   if [ -d .git ]; then
    return 0
   fi
  
   A=..
   while ! [ -d $A/.git ]; do 
    A="$A/.."
   done
   cd $A
  }
  </code></pre>
  
  <p>Do you have a better solution? (the function has been written quickly, suggestions are welcome)</p>