我如何从一个git回购签出一个文件?
当前回答
这对我很有用。使用git和一些shell命令
git clone --no-checkout --depth 1 git.example.com/project.git && cd project && git show HEAD:path/to/file_you_need > ../file_you_need && cd .. && rm -rf project
其他回答
这对我很有用。使用git和一些shell命令
git clone --no-checkout --depth 1 git.example.com/project.git && cd project && git show HEAD:path/to/file_you_need > ../file_you_need && cd .. && rm -rf project
是的,你可以通过这个命令下载一个特定的文件
wget -o <DesiredFileName> <Git FilePath>\?token\=<personalGitToken>
例子
wget -o javascript-test-automation.md https://github.com/akashgupta03/awesome-test-automation/blob/master/javascript-test-automation.md\?token\=<githubPersonalTone>
这听起来像是你试图从集中式版本控制中继承一个想法,而git本质上不是这样的——它是分布式的。如果你想使用git存储库,你可以克隆它。然后,您就拥有了工作树的所有内容和所有历史记录(好吧,至少是指向当前分支顶端的所有内容),而不仅仅是单个文件或单个提交的快照。
git clone /path/to/repo
git clone git://url/of/repo
git clone http://url/of/repo
如果您只需要下载文件,则不需要使用Git签出。
GitHub Mate更容易做到这一点,它是一个Chrome扩展,让你点击文件图标下载它。也是开源的
你可以通过
git archive --format=tar --remote=origin HEAD | tar xf -
git archive --format=tar --remote=origin HEAD <file> | tar xf -
推荐文章
- git可以自动在空格和制表符之间切换吗?
- Git暂存文件列表
- 如何将git配置存储为存储库的一部分?
- 如何修改GitHub拉请求?
- 如何在Github和本地删除最后n次提交?
- 我如何调试git/git-shell相关的问题?
- Python列表目录,子目录和文件
- 错误:无法使用rebase进行拉取:您有未分阶段的更改
- Git隐藏未缓存:如何把所有未分期的变化?
- 真实的恶魔
- 我如何知道我在S3桶中存储了多少对象?
- 如何从另一个分支获得更改
- Git:权限被拒绝(publickey)致命-无法从远程存储库读取。克隆Git存储库时
- git reflog和log有什么区别?
- git推挂在Total line之后