获取 git 存储库只读副本的最简单命令?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2234038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Simplest command to grab a read-only copy of a git repository?
提问by Mark Harrison
Here's a git repository on github:
这是 github 上的 git 存储库:
git://github.com/Fudge/gltail.git
git://github.com/Fudge/gltail.git
What's the simplest way to check out a read-only copy using the git command line tool?
使用 git 命令行工具检出只读副本的最简单方法是什么?
update:Here's a suggestion to the githubbers: Do something similar to google code, which automatically displays a message such as:
更新:这是给 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
update:The githubbers have done this.
更新:githubbers 已经做到了这一点。
回答by mipadi
git clone git://github.com/Fudge/gltail.git
回答by John Feminella
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
存储库的“只读副本”这样的东西。您可以使用以下命令克隆现有存储库:
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.
但与 Subversion 不同的是,git 中的每个“副本”本身都是一个全新的存储库。由于您可以提交到自己的存储库,因此从这个意义上说它肯定不是只读的。
回答by herve-guerin
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.
1)git clone --depth 1 git://github.com/Fudge/gltail.git
说明:当您索要副本时,您可能对该副本的完整历史不感兴趣。--depth 1
选项将下载限制为默认分支的最新版本,并且可能会显着减少要检索的数据量。
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.
2) 如果不想更新副本,可以删除副本根目录下的 .git 目录:它将切断与原始存储库的链接。
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.
否则,如果您需要确保永远不会修改原始存储库,则它必须由您对该原始存储库的访问权限进行管理。