I have a git repository that includes subdirectories. Example dirA/dirB. Is there any way to do a git clone
on a Unix server to pull only files from a subdirectory (dirB)?
Is there some other git command other than clone that will do this?
How do I git a specific file?
If you want to clone the git repository into the current directory, you can do like: $ git clone <repository> . Here, the dot (.) represents the current directory.
Step1: Input github url to the field at the top-right. Step2: Press enter or click download for download zip directly or click search for view the list of sub-folders and files. Step3: Click "Download Zip File" or "Get File" button to get files.
There are two ways to clone a specific branch. You can either: Clone the repository, fetch all branches, and checkout to a specific branch immediately. Clone the repository and fetch only a single branch.
You are good to continue exactly where you left off: your older branch, unstaged changes, etc. This will just copy the source folder to destination/source . The correct command is rsync -azv --exclude '. git' source/ destination/ , which copies contents of source folder to destination folder.
Suppose your project is in a dir called project
, and you want only those commits which touch project/dirB
.
Then:
git clone project/ subproject/ cd subproject git filter-branch --prune-empty --subdirectory-filter dirB HEAD
subproject
will now contain the git history which touches dirB
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With