12

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. My coding expertise draws the line at php and terminal scares me to no end. I've done plenty of research on reducing git repository sizes with mild success.

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.

What I've found:

Evidently, files on a git repository are not meant to be deleted with ease (For safety perhaps). There doesn't appear to be a way to just go to the repository highlight some stuff and hit delete. Thus far, however, I've found two promising leads right here in 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
  2. Many people suggesting a tool called the 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. 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? 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. 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.

Thank you in advance for any and all help.

Cheers, Omar

Community
  • 1
  • 1
user3389654
  • 141
  • 2
  • 5
  • Are you using Windows, Linux, or some other operating system? – Joseph K. Strauss May 05 '16 at 13:22
  • I am running El Capitan on an iMac – user3389654 May 05 '16 at 17:38
  • Unfortunately, I am not familiar with those systems. The short answer is that you will need to install command-line Git and have Java installed in order for the jar to work. – Joseph K. Strauss May 05 '16 at 17:46
  • Hmm... Well that's too bad. Thanks for helping out. I'm pretty sure I've been running command line Git through terminal and as far as Java, BFG requires Java 6 or higher which I've downloaded before (it's necessary for some games I run), so I know I've got both those things covered unless there's something I must do to be able to run Java on Terminal other than running the Java installer. – user3389654 May 05 '16 at 18:05

4 Answers4

8

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. 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.
  • 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 ~. So, I put the command like this: 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. 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.
  • To get help when you are stuck, you need to look for articles on how to use a terminal, or how to use bash. That tells you the general introductory stuff you need.
kim holder
  • 1,744
  • 3
  • 16
  • 25
  • Hey Kim. I know this is an old post, but I'd missed it and it's actually quite helpful for people just getting into it. I've no idea if this would've solved my problem because we've since departed from git entirely for our workflow, which is why I haven't marked it as the correct answer but I did upvote it because it's filled with things I wish I'd known back then. Thank you. – user3389654 Jun 21 '18 at 00:55
  • @user3389654 Thanks for that. I still struggle to follow instructions for things done in the terminal, because i misinterpret conventions, like [this] or sometimes {this}, and quotes, and stuff. I posted this answer partly to get that off my chest. Cheers. – kim holder Jun 21 '18 at 01:23
2

Go to the directory where this bfg.jar (name will be different for newer version) is copied and run the command below:

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

Skipper
  • 775
  • 6
  • 17
  • 32
Amarish
  • 21
  • 1
1

BFG requires minimum Java 7 since v1.12.5. 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.

Once you have java version 7 running from a command-prompt, just run:

$ 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.

javabrett
  • 7,020
  • 4
  • 51
  • 73
-1

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. Will it effect on all the branches like Develop / Master ?

2) $ java -jar bfg.jar Can we run this Jar from any location or any particular location we should download it.

Kbox
  • 21
  • 5