# Git



## gabrielalmeida (Sep 17, 2013)

Dear colleagues,

I am trying to extract sub-directories from a git repository and I have done so far these steps.

Filter subdirectory:
`git filter-branch --tag-name-filter cat --prune-empty --subdirectory-filter ./Subfolder HEAD` 

Delete history:
`git reset --hard git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d git reflog expire --expire=now --all git gc --aggressive --prune=now`

The problem is that it extracts all the tags and not the only ones from this repository. 

Would you have any idea how could I do it?

Thanks and regards.


----------



## expl (Sep 19, 2013)

_I'm n_ot entirely sure what you are trying to do, but this should do the job:

`git filter-branch --subdirectory-filter MySubDir -- --all`


----------

