{"componentChunkName":"component---src-templates-blog-post-js","path":"/blog/mirroring-private-git-repositories-locally-the-easy-way","result":{"data":{"allGhostPost":{"edges":[{"node":{"title":"Mirroring Private Git Repositories Locally: The Easy Way","html":"
Some of Capisso's projects depend on various private Cartalyst repositories. Since our code is open-source, we needed to allow everyone to access Cartalyst's repositories (Cartalyst's code is licensed under the OSI BSD 3 license which permits distributing code).
\nThe easiest way of mirroring a private git repo is as follows:
\nFor the sake of this post, the private repo will be git@github.com:example/repo.git.
\nStart off by setting up a webserver. DigitalOcean has some nice articles on doing that:
\nYou can skip the PHP/MySQL bit of the articles.
\nLet's assume our document root is /srv/www/git.domain.com/public_html.
\nSSH into your server.
\nssh user@IP\n
\nMake sure Git is installed:
\n\n# Ubuntu/Debian:\napt-get install git-core\n# CentOS/Fedora:\nyum install git\n
\ncd into your document root:
\ncd /srv/www/git.domain.com/public_html\n
\nClone the private repo as a bare repository:
\ngit clone --bare git@github.com:example/repo.git\n
\ncd into the bare repository and run git update-server-info:
\ncd repo.git\ngit update-server-info\n
\nEnable the default post-update hook that runs git update-server-info automatically when you pull:
\nmv hooks/post-update{.sample,}\n
\nThat's it. Your "private" repo is now ready for everyone to use. Make sure it works by trying to clone it locally and seeing if it works:
\ngit clone http://git.domain.com/repo.git\n
\n","published_at":"2013-07-24T18:50:00.000+03:00","slug":"mirroring-private-git-repositories-locally-the-easy-way","tags":[],"plaintext":"Some of Capisso [https://github.com/Capisso]'s projects depend on various\nprivate Cartalyst repositories. Since our code is open-source, we needed to\nallow everyone to access Cartalyst's repositories (Cartalyst's code is licensed\nunder the OSI BSD 3 license which permits distributing code).\n\nThe easiest way of mirroring a private git repo is as follows:\n\nFor the sake of this post, the private repo will be git@github.com\n:example/repo.git.\n\nStart off by setting up a webserver. DigitalOcean has some nice articles on\ndoing that:\n\n * I recommend this one: nginx on Ubuntu 12.04\n [https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04]\n * nginx on CentOS 6\n [https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-6]\n * Apache on Ubuntu\n [https://www.digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu]\n * Apache on CentOS 6\n [https://www.digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6]\n\nYou can skip the PHP/MySQL bit of the articles.\n\nLet's assume our document root is /srv/www/git.domain.com/public_html.\n\nSSH into your server.\n\nssh user@IP\n\n\nMake sure Git is installed:\n\n# Ubuntu/Debian:\napt-get install git-core\n# CentOS/Fedora:\nyum install git\n\n\ncd into your document root:\n\ncd /srv/www/git.domain.com/public_html\n\n\nClone the private repo as a bare repository:\n\ngit clone --bare git@github.com:example/repo.git\n\n\ncd into the bare repository and run git update-server-info:\n\ncd repo.git\ngit update-server-info\n\n\nEnable the default post-update hook that runs git update-server-info \nautomatically when you pull:\n\nmv hooks/post-update{.sample,}\n\n\nThat's it. Your \"private\" repo is now ready for everyone to use. Make sure it\nworks by trying to clone it locally and seeing if it works:\n\ngit clone http://git.domain.com/repo.git","meta_description":null}}]}},"pageContext":{"slug":"mirroring-private-git-repositories-locally-the-easy-way","prev":"highlighting-phps-files-in-nginx","next":"ip-tables-and-dynamic-dns"}},"staticQueryHashes":["3649515864"]}