I want to deploy the contents of a React's build folder to tomcat's webapps directory.
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). I want to pull the contents of that build file into a directory called dashboard/ in webapps/.
I've tried using sparse-checkout but what happens is the full path (/client/build) is placed in the dashboard directory. So instead of webapps/dashboard/contents of build folder the structure is webapps/dashboard/client/build/contents of build folder.
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?
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
is just a file name; 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
.1 The sparse checkout code will check it out using that name.
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; 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.
1I'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.