开发者

Command to get/clone a fetch/pull/read -only copy of a git repository?

Here's a git repository on github:

git://github.com/Fudge/gltail.git

What's the simplest way to check out a read-only copy using the git command line tool?

update: Here's开发者_如何转开发 a suggestion to the githubbers: Do something similar to google code, which automatically displays a message such as:

Use this command to anonymously check out the latest project source code:
    # Non-members may check out a read-only working copy anonymously over HTTP.
    svn checkout http://orapig.googlecode.com/svn/trunk/ orapig-read-only

update: The githubbers have done this.


git clone git://github.com/Fudge/gltail.git


The question is a bit misleading. There's not really such a thing as a "read-only copy" of a git repository. You can clone an existing repository with:

git clone git://example.com/path/to/repo.git

But unlike Subversion, every "copy" in git is itself a completely new repository. Since you can commit to your own repository, it's certainly not read-only in that sense.


I didn't found a real "read-only copy", but you can approach it by this way depending on your need :

1) git clone --depth 1 git://github.com/Fudge/gltail.git
Explanation : as you ask for a copy, you may not be interested by the full history of that copy.
--depth 1 option limits the download to the last version of the default branch and may reduce dramatically the amount of data to retrieve.

2) If you don't want to update your copy, you can remove the .git directory at the root of your copy : it will cut the link with the original repository.

Otherwise, if your need is to be sure that you never modify the original repo, it must be managed by your access rights on this original repo.


I've had to do this before, where a "read only" copy was a deployment copy versus a development copy. In addition to using --depth 1, we used a deployment key --but if you can't do that then you should be able to create a user for this that doesn't have write access to the repo, and prevent write access to that user's directories by other users with unix permissions. For a small team that needs a quick solution, this can work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜