Git/清理:修订间差异
来自康健生活
< Git
| 第18行: | 第18行: | ||
// 推送新的主分支到远程 | // 推送新的主分支到远程 | ||
</syntaxhighlight>|$|/home/kangkk}} | </syntaxhighlight>|$|/home/kangkk}} | ||
== 大文件 == | |||
检索 git 项目目录 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
git rev-list --objects --all</syntaxhighlight>|$|/home/kangkk}} | |||
延申出 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5 | awk '{print$1}')"</syntaxhighlight>|$|/home/kangkk}} | |||
删除大文件 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch <文件路径名称>' --prune-empty --tag-name-filter cat -- --s</syntaxhighlight>|$|/home/kangkk}} | |||
2025年4月21日 (一) 08:24的最新版本
标题文本
清理优化本地版本
/home/kangkk
git gc --prune=now
rebase
/home/kangkk
git rebase -i [commit_id]
orphan
/home/kangkk
git checkout --orphan <new-branch-name>
git add .
git commit -am "init"
// 删除所有本地旧分支
git branch -d <old-branch-name>
// 删除所有远程旧分支, 主分支需要临时打开分支保护
git push origin :<old-branch-name> -f
git checkout -b <main-branch-name>
// 推送新的主分支到远程
大文件
检索 git 项目目录
/home/kangkk
git rev-list --objects --all
延申出
/home/kangkk
git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5 | awk '{print$1}')"
删除大文件
/home/kangkk
git filter-branch --force --index-filter 'git rm -rf --cached --ignore-unmatch <文件路径名称>' --prune-empty --tag-name-filter cat -- --s
No categories