Reputation: 84
I want to clone the last committed files via Git. I tried the --depth 1 parameter. But the all project was cloned. I want to download only the last edited files because the project size is too high.
The command I tried;
git clone --depth 1 https://USERNAME:PASSWORD@HOST/PATH
I want to clone last edited and updated files. I don't want to go back to the previous committed files. I will analyze the last edited files with SonarQube. I don't want to clone the all project for this. And : I'm using exec with PHP to run commands.
How can I clone only the last edited files? Thank you.
Upvotes: 0
Views: 858
Reputation: 391
You can't just download a couple of files from a remote git repository. In order for git to restore a file, it must have all the data of the repository available. So unfortunately you will have to download the whole repository. If you would like to see which files have been changed, you can then run git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT HEAD
to receive a list of modified files.
Upvotes: 2
Reputation: 2254
$ git archive --format=tar --remote=<repository URL> HEAD | tar xf -
Also, if your browse remote repository using some web interface like Gitweb or GitHub, then it may have 'snapshot' feature with it and you can also download the newest version.
Upvotes: 1