xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

git whoami

git whoami

$ git config --list

$ git config --global  --list

# quit
$ q

$ git config user.name xgqfrms
$ git config user.email xgqfrms@xgqfrms.xyz

git push bug

HTTPS bug

# https bug
$ git clone https://github.com/xgqfrms/remove-git-commit-history

# $ git clone git@github.com:xgqfrms/remove-git-commit-history.git

SSH

SSH OK

# remove-git-commit-history
$ cd /Users/xgqfrms-mbp/Documents/GitHub/

# $ git clone https://github.com/xgqfrms/remove-git-commit-history
# SSH ok
$ git clone git@github.com:xgqfrms/remove-git-commit-history.git

$ cd remove-git-commit-history

$ git filter-branch --force --index-filter "git rm --cached --ignore-unmatch tools/sensitive-data.md" --prune-empty --tag-name-filter cat -- --all

$ echo "tools/sensitive-data.md" >> .gitignore

$ git push origin --force --all

$ git push origin --force --tags

# 强制取消引用本地仓库中的所有对象并进行垃圾回收 ???
$ git for-each-ref --format="delete %(refname)" refs/original | git update-ref --stdin
$ git reflog expire --expire=now --all
$ git gc --prune=now

从仓库中删除敏感数据

https://docs.github.com/cn/github/authenticating-to-github/removing-sensitive-data-from-a-repository

# ???

$ git filter-branch --force --index-filter \
  "git rm --cached --ignore-unmatch tools/sensitive-data.md" \
  --prune-empty --tag-name-filter cat -- --all
# OR 

# ???
$ cd tools
$ git filter-branch --force --index-filter \
  "git rm --cached --ignore-unmatch sensitive-data.md" \
  --prune-empty --tag-name-filter cat -- --all


git commits history 对比

https://github.com/xgqfrms/remove-git-commit-history/commits/master

before

after

SSH key

https://www.cnblogs.com/xgqfrms/p/5880270.html

SSH !== HTTPS ❌ ⚠️ bug

GitHub Desktop HTTPS bug, 要使用 SSH 通过 terminal clone 才行,

  1. HTTPS, 只能通过 GitHub Desktop 执行 git pull

https://github.com/xgqfrms/remove-git-commit-history

  1. SSH

git@github.com:xgqfrms/remove-git-commit-history.git

refs

https://alvinalexander.com/git/git-show-change-username-email-address/

posted @ 2020-07-19 12:20  xgqfrms  阅读(344)  评论(7编辑  收藏  举报