git 从 Github Repo 克隆单个文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37353458/
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
Cloning a Single File from Github Repo
提问by MadPhysicist
Is it possible to clone a single file from a remote repository with Git? For instance, I am looking to copy someone else's .htaccess file into my own project. I do not need their entire repository, just this one file.
是否可以使用 Git 从远程存储库克隆单个文件?例如,我希望将其他人的 .htaccess 文件复制到我自己的项目中。我不需要他们的整个存储库,只需要这个文件。
回答by Jonathan.Brink
Rather than clone, perhaps you can simply download the file.
而不是克隆,也许您可以简单地下载文件。
Assuming the repository is public, you can download a single file like this:
假设存储库是公开的,您可以像这样下载单个文件:
wget https://raw.githubusercontent.com/jquery/jquery/master/src/ajax.js
To get the url, navigate to the file in GitHub, and choose the "raw" view.
要获取 url,请导航到 GitHub 中的文件,然后选择“原始”视图。