diff --git a/content/git_serve.rst b/content/git_serve.rst new file mode 100644 index 0000000000000000000000000000000000000000..303e059f65fec0e74cba20a55e5a040096cca0a4 --- /dev/null +++ b/content/git_serve.rst @@ -0,0 +1,54 @@ +Ad-hoc serving of git repositories +################################## + +:date: 2016-08-16 +:summary: Ad-hoc serving of git repositories + +On some occasion you want to serve your git repo from your local copy (perhaps +your git repository is quite large and your internet connection is slow or your +build process would benefit from pulling from an intermediary without +authentication). Here are 2 ways to serve your git repository without any +configuration or software installation. Both ways serve a single repository +without authentication or encryption but readonly (no push). + +Using the git protocol +---------------------- + +The git executable is itself a git server using the native git protocol. Inside +the root of the repository run the following command + +.. code:: shell + + git daemon --reuseaddr --verbose --base-path=. --export-all ./.git + +And on the client you can clone by running + +.. code:: shell + + git clone git://servername/ reponame + + +Using the http protocol +----------------------- + +This way serves the repo over HTTP using Python 2's SimpleHTTPServer. Run the +following in the rot of the git repo + +.. code:: shell + + git update-server-info + cd .git + python -m SimpleHTTPServer + +And on the client clone by running + +.. code:: shell + + git clone http://servername:8000/ reponame + + +Final words +----------- + +I've added both ways as git aliases in my `rcfiles repo +<https://www.shore.co.il/cgit/rcfiles/tree/.gitconfig>`_.