Is it safe to re-clone Frappe apps with --depth 1 on a production server to reduce disk space?

Hi everyone,

I’m trying to reduce disk space usage on a production Frappe server.

Currently, all apps in the apps directory were cloned normally and contain the full Git history. I noticed that the .git directories consume a significant amount of disk space.

For example, if I have the frappe app under apps/frappe, can I do the following safely on a production server?

  1. Stop the bench.

  2. Remove the existing app directory:

    rm -rf apps/frappe
    
    
  3. Clone it again using a shallow clone:

    git clone --depth 1 <frappe-repo-url> apps/frappe
    
    
  4. Run bench setup requirements (if needed) and start the bench again.

Will this cause any issues with:

  • Existing sites and databases?

  • Future bench update operations?

  • App version detection?

  • Patches or migrations?

Has anyone done this successfully in production, or is there a recommended way to reduce Git history size for Frappe apps?

Thanks!

This is done in container images.

Thanks, @revant_one

I can see that in this setup they’re simply removing the .git directories to reduce the overall size. My scenario is a bit different. The production instance is already running, and initially I pulled the repositories normally to switch versions. Because of that, the size has increased across all applications due to the full Git history.

Now I’m considering replacing them with shallow clones (--depth 1) to reduce the size. If I remove an app directory and clone it again as a shallow repository, would that cause any issues?

My understanding is that it shouldn’t, since I’d just be replacing the source files on the machine with the same version/branch, but I wanted to confirm whether there are any concerns I should be aware of before doing this.