从git repo永久删除不需要的文件夹 - Repo大小不会更改 [英] Removing unwanted folders from git repo permanently - Repo size not changing

查看:486
本文介绍了从git repo永久删除不需要的文件夹 - Repo大小不会更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有git repo,我不小心将一些库文件提交到了git远程仓库。



现在它增加了大约6.23 GB的大小。然后我尝试使用以下命令删除库

  git filter-branch -f --index-filtergit rm -rf --cached --ignore-unmatch node_modules -  --all 
$ b $ r rm -rf .git / refs / original /
git reflog expire --expire = now --all
git gc --prune = now
git gc --aggressive --prune = now

现在库已从存储库中删除,并未列入回购文件夹中。但是,本地回购股票的规模仍然比以前更大另外一件事是执行上述命令需要很长时间。我不确定他们是否正常工作



我甚至尝试将此推送到远程回购,

  git push --all --force 

但没有成功推送,它会尝试到最后,并突然出现,因为远程repo无法访问或没有响应这种排序。

我也尝试重写标签

  git filter-branch -f \ --index-filter'git rm -r --cached --ignore-unmatch node_modules'\ --tag -name-filter'cat' -  --all 

我也尝试了以下操作来使其工作

  git config --global pack.windowMemory 0 
git config --global pack.packSizeLimit 0
git config --global pack.threads3

但是无论我做什么,repo的大小是仍然是相同的



注意:我试过

  git fsck  - 全 - 无法到达

列出了几个不可访问的标签

解决方案

我在 Git pull error:无法创建临时sha1文件名,单靠git gc是不够的。



应该降低回购规模的组合应该是:

  git gc 
git repack -Ad#杀死包装垃圾
git prune#杀死松散垃圾

但是,清理大文件( git filter-branch

在推送完成后( git push --force ),并且仅用于本地回购。 $ c>)远程回购,远程回购将不会受益于相同的规模减少。 gc / repack / prune也需要在远程端完成。



如果这个远端是TFS的话......这并不容易/现在可以做到


I have git repo, I have accidentally committed some library files to the git remote repo.

Now it has resulted in increased size of about 6.23 GB. Then I tried deleting the library using the following commands

git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch node_modules" -- --all

rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now

Now the library has been removed from the repository and it is not listed in the repo folders. But still the size of the local repo is bigger as before

One more thing is it takes a lot of time to execute the above commands. I am not sure whether they worked properly

I even did try pushing this to remote repo,

git push --all --force

but that doesnot get pushed successfully,It tries till the last and suddenly comes as the remote repo is not reachable or not responding of that sort

I also tried rewritting the tags

git filter-branch -f \ --index-filter 'git rm -r --cached --ignore-unmatch node_modules' \  --tag-name-filter 'cat' -- --all

I also tried the following to make it work

git config --global pack.windowMemory 0
git config --global pack.packSizeLimit 0
git config --global pack.threads "3"

But whatever I do the size of the repo is still the same

Note: I tried

git fsck --full --unreachable

There are several tags listed that are not reachable

解决方案

I mention in Git pull error: unable to create temporary sha1 filename that git gc alone isn't enough.

One combination which should bring down the size of the repo should be:

git gc
git repack -Ad      # kills in-pack garbage
git prune           # kills loose garbage

However, This must follow any cleanup of big file (git filter-branch), and that is only for the local repo.

After pushing (git push --force) to the remote repo, said remote repo won't benefit from the same size reduction. A gc/repack/prune needs to be done on the remote side as well.

And if that remote side is TFS... this isn't easy/possible to do for now.

这篇关于从git repo永久删除不需要的文件夹 - Repo大小不会更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆