1

如何清洗 Github 提交历史 ?

 2 years ago
source link: https://exp-blog.com/scm/qing-xi-github-ti-jiao-li-shi/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

如何清洗 Github 提交历史 ?


当 Github 的 Repo 变得日益臃肿、或者上传了敏感内容时,常见的方法时清理相关文件的所有历史提交记录:

shell
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch ${FILEPATH}' --prune-empty --tag-name-filter cat -- --all
git push origin master --force
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now

但若这类文件非常多的时候,一个可选的方法时直接清空所有历史记录:

shell
rm -rf .git
git init
git add -A
git commit -m "clear history"
git remote add origin ${GITHUB_REPO_URL}
git push -f -u origin master

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK