Skip to content

Instantly share code, notes, and snippets.

@yhordi
Last active August 29, 2015 14:26
Show Gist options
  • Save yhordi/6a7afbccebf31f13f89b to your computer and use it in GitHub Desktop.
Save yhordi/6a7afbccebf31f13f89b to your computer and use it in GitHub Desktop.
def find_git_root(path = Dir.pwd)
return nil if path == '/'
git_present = Dir.entries(path).include?('.git')
if !git_present
Dir.chdir(File.expand_path("..", Dir.pwd))
find_git_root(Dir.pwd)
end
p 'found git'
end
find_git_root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment