Git/清理:修订间差异
来自康健生活
创建页面,内容为“== 标题文本 == == 清理优化本地版本 == {{shc|<syntaxhighlight lang="bash"> git gc --prune=now</syntaxhighlight>|$|/home/kangkk}}” |
|||
| (未显示同一用户的3个中间版本) | |||
| 第3行: | 第3行: | ||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
git gc --prune=now</syntaxhighlight>|$|/home/kangkk}} | git gc --prune=now</syntaxhighlight>|$|/home/kangkk}} | ||
== rebase == | |||
{{shc|<syntaxhighlight lang="bash"> | |||
git rebase -i [commit_id]</syntaxhighlight>|$|/home/kangkk}} | |||
== orphan == | |||
{{shc|<syntaxhighlight lang="bash"> | |||
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> | |||
// 推送新的主分支到远程 | |||
</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}} | |||