Last Updated: February 25, 2016
· zzet

Save tags and branches with git filter-branch

If you want run git filter-branch and save refs, you must add --tag-name-filter 'cat' to your command.

For example:

I replace in repository (from file .gitmodules) git:// with git:// and want to save tags.

My command like this:

git filter-branch --tag-name-filter 'cat' --tree-filter '
    if [ -f .gitmodules ];
        cat .gitmodules | sed -e "s/\+[a-zA-Z]*\///g" >> .tmpgitmodules && mv .tmpgitmodules .gitmodules;
        echo "";
      fi' -- --all

After run I save all refs. They was updated from old to new sha.