0

I have a git repo like

repo
/sub-project1
 /sub-folders and files
/sub-project2
 /sub-folders and files
/sub-project3
 /sub-folders and files

i want to remove

 /sub-project1
     /sub-folders and files

and create a new repo with all the git history related to that folder and files need to be also included.

main consideration is keep only the history related to that folder only and remove all other unwanted history

what is the best way to do it?

  • 2
    Possible duplicate of [Detach (move) subdirectory into separate Git repository](https://stackoverflow.com/questions/359424/detach-move-subdirectory-into-separate-git-repository) – phd Mar 22 '19 at 05:55
  • https://stackoverflow.com/search?q=%5Bgit%5D+detach+directory – phd Mar 22 '19 at 05:56
  • @phd thanks for your comment. problem is that im getting all the history of the parent repo. i just need the history related to that sub folder only – Thilina Dinith Fonseka Mar 22 '19 at 06:16
  • 1
    This approach should work. Just make sure, that you type commands properly, and they are executed without errors/warnings. – kosist Mar 22 '19 at 06:42
  • @kosist thank for your reply. tried those. but the issue is all the history trace is coming with the new repo which i dont want. i want only the specific folder's history in the new repo only. – Thilina Dinith Fonseka Mar 22 '19 at 06:44

1 Answers1

1

keep only the history of the desired folder. need to use following command

git filter-branch --tag-name-filter cat --prune-empty --subdirectory-filter <folder-name> -- --all