Discover ref automatically. Exclude .git and .svn.