简体   繁体   English

如何使用.jar工具BFG Repo Cleaner并减少git存储库?

[英]How to use .jar tool BFG Repo Cleaner and reduce git repository?

I have a question that I am sure is very simple but which I can't find the answer for. 我有一个非常确定的问题,但我找不到答案。 I am an animator working on the Unreal Engine 4 and using Source Control, Bitbucket and Source Tree to collaborate on a current project. 我是一名动画师,在Unreal Engine 4上工作,并使用Source Control,Bitbucket和Source Tree在当前项目中进行协作。 My coding expertise draws the line at php and terminal scares me to no end. 我的编码专业知识使php陷入困境,而终端却使我无休止。 I've done plenty of research on reducing git repository sizes with mild success. 我在减少git仓库大小方面进行了大量研究,并取得了一定的成功。

The Case: I've run out of space on my Repository (probably because UE4 saves a million auto save files every time I use it) and need to delete some files. 案例:我的存储库空间不足(可能是因为UE4每次使用都会保存一百万个自动保存文件),并且需要删除一些文件。

What I've found: 我发现了什么:

Evidently, files on a git repository are not meant to be deleted with ease (For safety perhaps). 显然,git存储库中的文件并不能轻易删除(也许出于安全考虑)。 There doesn't appear to be a way to just go to the repository highlight some stuff and hit delete. 似乎没有一种方法可以仅转到存储库中突出显示一些内容并单击Delete。 Thus far, however, I've found two promising leads right here in StackOverflow. 但是到目前为止,我在StackOverflow中找到了两个有希望的线索。

  1. This awesome little bit of code from Sam Watkins which gave me some good results: http://sam.nipl.net/b/git-gc-all-ferocious 萨姆·沃特金斯Sam Watkins)的这段很棒的代码给了我一些很好的结果: http : //sam.nipl.net/b/git-gc-all-ferocious
  2. Many people suggesting a tool called the BFG Repo Cleaner. 许多人建议使用一种名为BFG Repo Cleaner的工具。

What I'd like to know: 我想知道的是:

  1. From what I've read, BFG seems to be the fastest and most efficient solution to repository reduction out there. 根据我的阅读,BFG似乎是那里减少存储库的最快,最有效的解决方案。 Is this an accurate assessment? 这是准确的评估吗?

  2. There are many resources online on how to use the tool, ( such as this one ) but none that answer my (very basic, I imagine) question. 在线上有很多关于如何使用该工具的资源( 例如这一资源 ),但是没有一个资源可以回答我的问题(我想很基本)。 After I download it, what do I do with the file? 下载后,该如何处理文件? Do I just double click it? 我是否只需双击它? Does the .jar file need to be in a specific place? .jar文件是否需要放在特定位置? Must I run it and then follow the instructions? 我必须先运行它,然后按照说明进行操作吗?

What I've tried: 我尝试过的

  1. I double clicked it and it seems to have run but it had no effect. 我双击它,它似乎已运行,但没有效果。

  2. I tried running the code snippets from several walkthrough articles (including the one I've linked to above) through terminal using source tree's terminal button and replacing all the placeholder urls with mine on the copied code, but any snippet that contains the words bfg.jar fails. 我尝试使用源树的终端按钮通过终端运行多个演练文章(包括我上面链接到的文章)中的代码片段,并在复制的代码上用我的所有占位符url替换,但是任何包含单词bfg的代码段。 jar失败。 All the code I've found online for the tool returns a "command not found" message in terminal, which is not surprising since the tool is just sitting in my downloads folder. 我在网上为该工具找到的所有代码都在终端中返回“找不到命令”消息,这并不奇怪,因为该工具只是位于我的下载文件夹中。

  3. I've looked at "working with .jar files" articles but all I could find seems to be more interested in coding such files than running them, and so, I am at a loss. 我看过“使用.jar文件”的文章,但是我发现所有似乎都比运行它们对编码这样的文件更感兴趣,所以,我很茫然。

Thank you in advance for any and all help. 预先感谢您提供的所有帮助。

Cheers, Omar 干杯,奥马尔

Things that help when you are new to the terminal, that you will almost never find, in instructions for programs that run in a terminal: 在终端机上运行的程序的说明中,对于终端机新手有帮助的事情几乎是永远找不到的:

  • You need to specify the exact name of the file to run. 您需要指定要运行的文件的确切名称。 In my case, the latest version was bfg-1.12.15.jar . 就我而言,最新版本是bfg-1.12.15.jar Either you rename the file to bfg.jar (but you might not want to if later you want to know the version you have), or you type it in just like that. 您可以将文件重命名为bfg.jar(但是稍后可能不想知道所拥有的版本),或者像这样键入文件。
  • You need to specify the exact path to the file to run. 您需要指定要运行的文件的确切路径。 In my case, it was in the home folder of my Ubuntu system, which is the root folder, and is denoted with a tilde ~ . 在我的情况下,它位于我的Ubuntu系统的主文件夹中,该主文件夹是根文件夹,并用波浪号~表示。 So, I put the command like this: java -jar ~/bfg-1.12.15.jar . 所以,我这样输入命令: java -jar ~/bfg-1.12.15.jar You can specify any path by starting from the root folder and indicating folders nested within it with a forward slash, like ~/Music/Funk/James_Brown/get-on-up.mp3 , for instance. 您可以通过从根文件夹开始并以正斜杠指示嵌套在其中的文件夹来指定任何路径,例如~/Music/Funk/James_Brown/get-on-up.mp3 The program will run from anywhere if the OS knows where to find it. 如果操作系统知道在哪里可以找到该程序,它将在任何地方运行。
  • You need to be in the directory where you want the program to do its work, and run it from there. 您需要位于要程序执行其工作的目录中,然后从那里运行它。 To change directories (also known as folders), the command is cd , then you specify the path as shown above. 要更改目录(也称为文件夹),命令是cd ,然后指定路径,如上所示。
  • To get help when you are stuck, you need to look for articles on how to use a terminal, or how to use bash. 为了在遇到困难时获得帮助,您需要查找有关如何使用终端或如何使用bash的文章。 That tells you the general introductory stuff you need. 这告诉您所需的一般入门资料。

BFG requires minimum Java 7 since v1.12.5. 自v1.12.5起,BFG至少需要Java 7。 There is no UI, so you need to become comfortable running it from the command-line, but there is sufficient documentation available to succeed on the website . 没有用户界面,因此您需要习惯于从命令行运行它,但是有足够的文档可以在该网站上获得成功。 Double-clicking the jar file won't get you anywhere. 双击jar文件将无处可寻。

Once you have java version 7 running from a command-prompt, just run: 从命令提示符运行java版本7后,只需运行:

$ java -jar bfg.jar

... to generate the usage/options, or refer to the website. ...以生成用法/选项,或访问网站。

To answer your question 1), within the restrictions imposed by its approach, BFG is indeed the fastest tool around that I am aware of for rewriting history whilst removing files. 要回答您的问题1),在其方法施加的限制内,BFG确实是我所知的最快的工具,用于在删除文件的同时重写历史记录。

转到复制此bfg.jar (新版本的名称将不同)的目录,然后运行以下命令:

java -jar bfg-1.13.0.jar --strip-blobs-bigger-than 50M <Cloned GitRepo Path>

1) $ java -jar bfg.jar --replace-text replacements.txt my-repo.git Once we run this command will it automatically commit to GitHub or we would require to explicitly commit it post changes. 1)$ java -jar bfg.jar --replace-text replacements.txt my-repo.git一旦运行此命令,它将自动提交到GitHub,或者需要在更改后明确提交。 Will it effect on all the branches like Develop / Master ? 它会影响像Develop / Master这样的所有分支吗?

2) $ java -jar bfg.jar Can we run this Jar from any location or any particular location we should download it. 2)$ java -jar bfg.jar我们可以从任何位置或任何特定位置运行此Jar,我们应该下载它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM