【发布时间】:2019-05-27 17:21:18
【问题描述】:
我正在使用 BFG 删除我的两个文件夹。从回购开始就对它们进行了跟踪。删除的原因是那些文件夹包含我们不再需要的二进制文件和其他 txt 文件。但是当我尝试删除这两个文件夹时,一个被删除了,但另一个仍然存在。
我创建了我的虚拟仓库并做了一些提交来重现问题。 我假设 myRepo.git 一开始就是干净的仓库。
我用来删除文件夹的功能是:
java -jar bfg-1.13.0.jar --no-blob-protection --delete-folders "{system1, system2}" myRepo.git
#!/bin/bash
BUILD(){
git clone https://github.com/xxxx/myRepo.git
cd myRepo
echo "Jpt test1" > jpt1.txt
echo "Jpt test2" > jpt2.txt
echo "Jpt test3" > jpt3.txt
git add jpt1.txt jpt2.txt jpt3.txt
git commit -m "first commit"
git push origin master
######
mkdir system1
cd system1
mkfile 14m outputfile1.out
mkfile 14m outputfile2.out
echo "Jpt test1" > sysjpt1.txt
echo "Jpt test2" > sysjpt2.txt
echo "Jpt test3" > sysjpt3.txt
cd ..
######
mkdir system2
cd system2
mkfile 14m outputfile1.out
mkfile 14m outputfile2.out
cd ..
git add system1 system2
git commit -m "tracking large file"
git push origin master
cd ..
##### Call function BFG which does BFG stuff.
BFG
}
BFG(){
# run bfg and let git clean history
git clone --mirror https://github.com/xxxx/myRepo.git
java -jar bfg-1.13.0.jar --no-blob-protection --delete-folders "{system1, system2}" myRepo.git
cd myRepo.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push
cd ..
mkdir test_new
cd test_new
git clone https://github.com/xxx/myRepo.git
cd myRepo
ls
}
BUILD
当我在清理后克隆并对其执行ls 时。我明白了
jpt1.txt jpt2.txt jpt3.txt system2。看看 system2 文件夹如何仍然存在。
【问题讨论】:
-
澄清一下,
system2还在,但文件还在吗?另外,我不喜欢"{system1, system2}"。通过在其周围加上引号,您将该字符串按原样传递给 bfg,而不是让 shell 扩展它。逗号后面的空格也似乎是个坏主意。您是否尝试过在两个命令中运行它,每个文件夹一个? -
是的,其他文件也在那里。我会尝试你的建议并让你知道。
-
@joanis 所以我试着像你说的那样,分开做它们,它起作用了。正如您所说,问题可能出在脚本的
"{system1, system2}"部分。 -
在使用命令
java -jar bfg-1.13.0.jar --no-blob-protection --delete-folders "{system1, system2}" myRepo.git进行更多操作并重新阅读您的评论The space after the comma also seems like a bad idea.之后。我试过没有空间,它似乎工作。所以我可以确认空间是问题所在。所以我运行的最后一个命令是java -jar bfg-1.13.0.jar --no-blob-protection --delete-folders "{system1,system2}" myRepo.git看看现在有多少空间 `"{system1,system2}"。 -
好的,谢谢你告诉我。那我把它写下来作为答案。
标签: git bfg-repo-cleaner