获取/克隆 git 存储库的获取/拉取/只读副本的命令?
这是 github 上的 git 存储库:
git://github.com/Fudge/gltail.git
使用 git 命令行工具查看只读副本的最简单方法是什么?
更新: 这是对 githubbers 的建议:做一些类似于 google code 的事情,它会自动显示一条消息,例如:
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
更新: githubbers 已经这样做了。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这个问题有点误导。实际上并不存在
git
存储库的“只读副本”这样的东西。您可以使用以下方式克隆现有存储库:但与 Subversion 不同的是,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: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.
我没有找到真正的“只读副本”,但您可以根据您的需要通过这种方式接近它:
1)
git clone --深度1 git://github.com/Fudge/gltail。 git
说明:当您索取副本时,您可能对该副本的完整历史不感兴趣。
--depth 1
选项将下载限制为默认分支的最新版本,并且可能会显着减少要检索的数据量。2) 如果您不想更新副本,可以删除副本根目录下的 .git 目录:它将切断与原始存储库的链接。
否则,如果您需要确保永远不会修改原始存储库,则必须通过您对此原始存储库的访问权限进行管理。
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.
我以前必须这样做,其中“只读”副本是部署副本而不是开发副本。除了使用 --depth 1 之外,我们还使用了部署密钥 -- 但如果您不能这样做,那么您应该能够为此创建一个没有存储库写访问权限的用户,并阻止写访问权限具有 unix 权限的其他用户访问该用户的目录。对于需要快速解决方案的小团队来说,这是可行的。
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.