How do you use Git to retrieve just one (or a few) files from a repo? [duplicate]

廉价感情. 提交于 2019-12-04 02:15:41

问题


Possible Duplicate:
Partial clone with Git and Mercurial

I switched into the specific directory into which I'd like my repo file to be copied into, and then tried the following:

    git clone git@github.com:path/to/file.java

but it's giving me ERROR: repository not found

Can anyone tell me what's going on, and what's the right thing to do? (a little background doesn't hurt!)


回答1:


You may want to look into something called a sparse checkout which was implemented in Git 1.7 I believe. Before that I don't think git allowed you to do so although on github you can always copy individual files from their web interface by opening the file and saving it.




回答2:


git works at the repository level, not at the file level (unlike CVS/SVN).

As a result, if you clone you usually clone the whole repo - and a change is tracked as a repository content change - not a simple file change.



来源:https://stackoverflow.com/questions/10004508/how-do-you-use-git-to-retrieve-just-one-or-a-few-files-from-a-repo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!