git-root

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 ..).

 •  0 comments  •  flag
Share on Twitter
Published on November 06, 2014 12:20
No comments have been added yet.


Nicholas Cloud's Blog

Nicholas Cloud
Nicholas Cloud isn't a Goodreads Author (yet), but they do have a blog, so here are some recent posts imported from their feed.
Follow Nicholas Cloud's blog with rss.