简体   繁体   English

是否可以仅对 git repo 的子目录中的文件进行稀疏结帐?

[英]Is it possible to sparse-checkout only the files in a sub-directory of a git repo?

I want to deploy the contents of a React's build folder to tomcat's webapps directory.我想将 React 的 build 文件夹的内容部署到 tomcat 的 webapps 目录。

The project on Github is called dashboard and it has a sub-directory called client which holds the development code as well as the production build file (/client/build). Github 上的项目称为仪表板,它有一个名为 client 的子目录,其中包含开发代码以及生产构建文件 (/client/build)。 I want to pull the contents of that build file into a directory called dashboard/ in webapps/.我想将该构建文件的内容拉入 webapps/ 中名为dashboard/ 的目录中。

I've tried using sparse-checkout but what happens is the full path (/client/build) is placed in the dashboard directory.我试过使用 sparse-checkout 但发生的情况是完整路径 (/client/build) 被放置在仪表板目录中。 So instead of webapps/dashboard/ contents of build folder the structure is webapps/dashboard/client/build/ contents of build folder .因此,不是 webapps/dashboard/构建文件夹内容,结构是 webapps/dashboard/client/build/构建文件夹的内容

Is there a way to only extract the files from a folder with sparse-checkout or is there a way to configure tomcat to look into /client/build for the files it needs?有没有办法只从带有稀疏结账的文件夹中提取文件,或者有没有办法配置 tomcat 以查看 /client/build 以获取它需要的文件?

You can use sparse checkout mode to check out a limited subset of files, but you cannot use this to rename the files.可以使用稀疏检出模式检出有限的文件子集,但不能使用它来重命名文件。 If the file's name is a/b/c/d —note that file names don't contain folder names;如果文件名是a/b/c/d d——注意文件名不包含文件夹名; a/b/c/d is just a file name; a/b/c/d只是一个文件名; it is your OS, not Git, that insists on storing this as a file d within a folder c and so on—then as far as Git is concerned, that file's name is a/b/c/d .是您的操作系统,而不是 Git,坚持将其作为文件d存储在文件夹c ,依此类推——然后就 Git 而言,该文件的名称是a/b/c/d 1 The sparse checkout code will check it out using that name. 1稀疏检出代码将使用该名称检出。

What you can do quite easily is use git archive to produce a tarball or zip archive, then use any un-archiver that allows you to skip some number of pathname components;可以很容易地做的是使用git archive来生成一个 tarball 或 zip 存档,然后使用任何允许你跳过一些路径名组件的 un-archiver; or, if you have just a single file to extract, use git show or git cat-file -p to extract the file, and direct the output of this command to a file.或者,如果您只有一个文件要提取,请使用git showgit cat-file -p提取文件,并将此命令的输出定向到一个文件。


1 I'm thinking about a general method of handling file renaming issues, but it's still in formative stages, and there's no guarantee that the Git project folks will buy into anything I come up with here. 1我正在考虑处理文件重命名问题的一般方法,但它仍处于形成阶段,并且不能保证 Git 项目人员会购买我在这里提出的任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM