Git checkout just a subdirectory

▼魔方 西西 提交于 2020-01-03 03:09:08

问题


Please note: I am not looking for git sparse checkout, nor is this question a duplicate of Is there any way to clone a git repository's sub-directory only?

In git, is it possible to clone or checkout just a subdirectory, into the current directory? In svn, you would do this by extending the URL. For example, instead of checking out http://server/repo you would checkout http://server/repo/subdir

The difference between sparse checkout and checking out only a subdir, is that a sparse checkout still creates a local directory subdir. I don't want a subdirectory called subdir. I want the contents of subdir to be checked out into the top level of my working copy.

An example use case would be:

  • I clone https://github.com/jquerytools/www.git
  • I don't like their css so I do a sparse checkout or use ignores to exclude their css from my checkout.
  • I want to use the source/css subdirectory from https://github.com/mozfr/www.git and it must appear in the local css directory

来源:https://stackoverflow.com/questions/37603528/git-checkout-just-a-subdirectory

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