Remove refs/original/heads/master from git repo after filter-branch --tree-filter?

前端 未结 3 1603
孤街浪徒
孤街浪徒 2020-11-27 09:11

I had the same question as asked here: New git repository in root directory to subsume an exist repository in a sub-directory

I followed this answer here: New git re

相关标签:
3条回答
  • 2020-11-27 09:51

    And if you're in Windows PowerShell:

    git for-each-ref --format="%(refname)" refs/original/ | foreach-object -process { git update-ref -d $_ }
    
    0 讨论(0)
  • 2020-11-27 09:54

    refs/original/* is there as a backup, in case you mess up your filter-branch. Believe me, it's a really good idea.

    Once you've inspected the results, and you're very confident that you have what you want, you can remove the backed up ref:

    git update-ref -d refs/original/refs/heads/master
    

    or if you did this to many refs, and you want to wipe it all out:

    git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
    

    (That's taken directly from the filter-branch manpage.)

    This doesn't apply to you, but to others who may find this: If you do a filter-branch which removes content taking up significant disk space, you might also want to run git reflog expire --expire=now --all and git gc --prune=now to expire your reflogs and delete the now-unused objects. (Warning: completely, totally irreversible. Be very sure before you do it.)

    0 讨论(0)
  • 2020-11-27 09:59

    filter-branch keeps backups so repository need to clean up reflogs and garbage collect. Make sure that have no need in this backups before deletion:

    rm -Rf .git/refs/original
    git gc --aggressive --prune=now
    
    0 讨论(0)
提交回复
热议问题