git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Can I prevent someone clone my git repository?

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 8, 2009, 08:36 UTC
Message-ID
<7vr63e42ke.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<856bfe0e0901072303i4fcd3bf6u99790ab9f4170937@mail.gmail.com>
"Emily Ren" <lingyan.ren@gmail.com> writes:
> I want some person can clone my git repository, others can't clone my
> git repository. Is it realizable ? How to do it?
It depends on what transport these people come from.

On the local filesystem transport (either same host or network-mounted filesystem), you do it the same way as you solve "how do I show these files of mine on the local computer to some but not others". Typically, you place these group members in the same UNIX group, make the toplevel directory of the hierarchy owned by the group, and "chmod g+rx,o=" it (and make everything underneath group readable). Setting core.sharedrepository configuration variable would help maintain the group readability.

If they come over the http transport, you would solve it the same way as you solve "how do I allow access to these files on my webserver to only selected few?" Probably .htaccess file in the toplevel directory will be involved.

You can set up gitosis and have it serve your repository, and register group members' SSH keys to gitosis. It allows you to categorize these users into different groups, and assign read-only or read-write access to repositories. When this is done, these people will be coming over the "git over ssh" transport, i.e. git@your-host:/path/to/repository.git/ or its synonym ssh://git@your-host/path/to/repository.git/

The git-daemon transport deliberately omits authentication, and you cannot restrict when they come over the git native transport using a URL like git://your-host/repository.git

-jc
Previous: Emily RenNext: Johannes Sixt
Message 2 of 12 in “Can I prevent someone clone my git repository?”
  1. Emily RenJan 8, 2009
  2. Junio C HamanoJan 8, 2009
  3. Johannes SixtJan 8, 2009
  4. Emily RenJan 8, 2009
  5. Johannes SixtJan 8, 2009
  6. Johannes SchindelinJan 8, 2009
  7. Miklos VajnaJan 8, 2009
  8. Johannes SchindelinJan 8, 2009
  9. Shawn O. PearceJan 8, 2009
  10. Johannes SchindelinJan 8, 2009
  11. Shawn O. PearceJan 8, 2009
  12. Johannes SchindelinJan 8, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.