1

I have new structure (new repository and its own branches) for new version of my project , and i need to clone some parts of last version to keep history of old commits for new programmers. let say my old repository include whole project with all plugins , and in this version we focus only on plugins and we do not want to clone whole project , but those plugins which we use must have git history to check old commit. how it possible ?

Pentagon
  • 123
  • 10
  • Possible duplicate of [Git - clone only part of the repository and get pulls only for that part?](https://stackoverflow.com/questions/34103146/git-clone-only-part-of-the-repository-and-get-pulls-only-for-that-part) – phd Jun 27 '18 at 16:14

1 Answers1

0

You can clone the whole repository and then remove the unwanted parts using git filter-branch.

This is how you remove a single file from the repository history:

git filter-branch --prune-empty --index-filter 'git rm --cached --ignore-unmatch filename' HEAD

where filename is the path to the file you want to remove.

Or if the part you want to keep is in a single directory, you can do

git filter-branch --subdirectory-filter foodir -- --all

This rewrites the history as if foodir/ had been its project root and discards all other history.

Read documentation carefully to apply it for your specific case.

buff
  • 2,063
  • 10
  • 16