By Chen Hui Jing / @hj_chen
🎮 🏀 🚲 💻 👟
My name is Chen Hui Jing.
Self taught designer and developer.
Write blog posts from time to time.
Love HTML and CSS very much.
git filter-branch --index-filter 'git rm -rf --cached --ignore-unmatch FOLDER_NAME' --prune-empty --tag-name-filter cat -- --all
git filter-branch --index-filter 'git rm -rf --cached --ignore-unmatch FOLDER_NAME' --prune-empty --tag-name-filter cat -- --all
Hey, it's a pretty long line. ¯\_(ツ)_/¯
filter-branch --index-filter
filter-branch command allows you to rewrite the Git history--index-filter rewrites the index--tree-filter but --index-filter is faster because it does not check out the tree'git rm -rf --cached --ignore-unmatch FOLDER_NAME'
--index-filter for optimal resultsrm) and forcefully(-rf)--cached is used to unstage and remove paths from the index--ignore-unmatch will prevent the command from failing if the file is absent from the tree of a commit--prune-empty --tag-name-filter cat
--prune-empty allows the filter-branch command to ignore empty commits generated by the filters applied-tag-name-filter cat will update the relevant tags by rewriting them-- --all
-- simply separates the filter-branch options from the revision options--all will rewrite ALL branches and tagsgit filter-branchgit prune
git prunerm -rf .git/refs/original/
git reflog expire --expire=now --all
expire is used to prune older reflog entries--expire=now specifies how far behind these older entries should be, in this case, right nowgit refloggit gc --prune=now
--prune=now prunes objects older than the date specified, in this case, right nowgit gcgit clone --no-hardlinks file://PATH/TO/OLD-REPO NEW-REPO