I wrote a little bash alias a while ago to help me instantly to the root directory of a git project from any directory beneath it.
.gist table { margin-bottom: 0; }
It’s pretty simple. Assume /projects/foo is the root of a project under git. Assume your pwd is /projects/foo/bar/baz. At the prompt, typing git-root will return you to /projects/foo.
This works by changing pwd to be the actual .git directory under the project root, and then backing out of it one level up (to ..).
Published on November 06, 2014 12:20