Git filter branch - Detach many subdirectories into a new separate Git repository

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository

Instead of detaching a single subdirectory, I want to detach a couple. For example, my current directory tree looks like this:

/apps
  /AAA
  /BBB
  /CCC
/libs
  /XXX
  /YYY
  /ZZZ

And I would like this instead:

/apps
  /AAA
/libs
  /XXX

The --subdirectory-filter argument to git filter-branch won t work because it gets rid of everything except for the given directory the first time it s run. I thought using the --index-filter argument for all unwanted files would work (albeit tedious), but if I try running it more than once, I get the following message:

Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f

Any ideas? TIA

Answers

Instead of having to deal with a subshell and using ext glob (as kynan suggested), try this much simpler approach:

git filter-branch --index-filter  git rm --cached -qr --ignore-unmatch -- . && git reset -q $GIT_COMMIT -- apps/AAA libs/XXX  --prune-empty -- --all

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/2982055/detach-many-subdirectories-into-a-new-separate-git-repository

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils