[alias]
serve = "!f(){ printf \"Starting git-daemon for $(pwd) @ 'git://$(hostname)/$(basename $(pwd))'.\nExample: git clone git://$(hostname)/$(basename $(pwd)) [<directory>]\n\"; git daemon --base-path=.. --reuseaddr --informative-errors --verbose --export-all ../$(basename $(pwd)) ; }; f"
Most serve aliases I've seen exports the current directory using itself as base path, which anonymizes the actual repository beeing shared (git://<addr>
) unless sharing the parent directory which cause all repositories there to become exported.
This alias exports the current directory using the parent directory as base so the repository URL will be like
git://<addr>/my-repo
.
It also prints the URL that can be used to access the exported repository when the daemon starts.