git filter-branch
# Rewrite branches
$ git filter-branch
$ git filter-branch [--setup ] [--subdirectory-filter ]
[--env-filter ] [--tree-filter ]
[--index-filter ] [--parent-filter ]
[--msg-filter ] [--commit-filter ]
[--tag-name-filter ] [--prune-empty]
[--original ] [-d ] [-f | --force]
[--state-branch ] [--] […]
https://git-scm.com/docs/git-filter-branch
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
demo
# clone the repository to your local computer.
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
# Navigate into the repository's working directory.
$ cd YOUR-REPOSITORY
# filter & remove
$ git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA" \
--prune-empty --tag-name-filter cat -- --all
$ echo "YOUR-FILE-WITH-SENSITIVE-DATA" >> .gitignore
$ git add .gitignore
$ git commit -m "Add YOUR-FILE-WITH-SENSITIVE-DATA to .gitignore"
git in action
https://github.com/xgqfrms/xgqfrms/blob/c4b676cde81032acae8ca8485866527abcdfbb86/tools/WebStrom-2016.2.4.md
https://github.com/xgqfrms/xgqfrms/blob/gh-pages/tools/WebStrom-2016.2.4.md
$ git clone https://github.com/xgqfrms/xgqfrms
# git checkout gh-pages
$ cd github/xgqfrms
$ git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch tools/WebStrom-2016.2.4.md" \
--prune-empty --tag-name-filter cat -- --all
# what's `\` & `""` means in git cli???
$ git filter-branch --force --index-filter "git rm --cached --ignore-unmatch tools/WebStrom-2016.2.4.md" --prune-empty --tag-name-filter cat -- --all
$ echo "tools/WebStrom-2016.2.4.md" >> .gitignore
$ git add .gitignore
$ git commit -m "Add YOUR-FILE-WITH-SENSITIVE-DATA to .gitignore"
testing remove-git-commit-history
https://github.com/xgqfrms/xgqfrms/remove-git-commit-history
$ git clone https://github.com/xgqfrms/remove-git-commit-history
$ cd github/remove-git-commit-history
$ git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch tools/WebStrom-2016.2.4.md" \
--prune-empty --tag-name-filter cat -- --all
GitHub SSH key
.po
translate
https://raw.githubusercontent.com/jnavila/git-manpages-l10n/master/po/documentation.zh_HANS-CN.po
refs
https://docs.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository
https://docs.github.com/cn/github/authenticating-to-github/removing-sensitive-data-from-a-repository
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!