how can I have a remote git repo which is accessible via http but only for cloning?
Maybe with the help of nginx (already running) and git-http-backend
(git-http-fetch
?).
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
NOTE: I assume that you meant anonymous read-only access; there is no way to distinguish between clone and fetch in git, I think.
Do you want to set up "smart" HTTP (recommended), or "dumb" HTTP one?
For "dumb" HTTP it is enough to forbid (or just do not set up) WebDAV - this is how pushes come with "dumb" HTTP (no git on server side).
For "smart" HTTP follow directions for anonymous read access but authenticated write access in git-http-backend manpage, translating it from Apache to nginx, and modifying slightly. Note that documentation for anonymous read but authenticated write might be incomplete, but you do not worry about authenthicated write (push) access succeding anyway, isn't it?
In his answer, Jakub Narębski suggests:
Following his suggestion, I configured nginx and
git-http-backend
to enable anonymous read access but authenticated write access by using a combination ofif
,$arg
, andrewrite
to differentiate between Git read and write operations before invokinggit-http-backend
:Configuration file
/etc/nginx/git-http-backend.conf
contains the commonfastcgi
directives that prepare the environment forfastcgi
to invokegit-http-backend
:Maybe this is what you are looking for
git daemon
: Git serve: I would like it that simpleThere are many interesting answers on that page but none specifically for nginx.
You could then add a proxy pass in nginx like so:
I don't know of a way of allowing only cloning... but the
git daemon
command is already read-only. So it should do it's job.I hope this helps !