Skip to content

Instantly share code, notes, and snippets.

@agritheory
Last active April 24, 2023 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agritheory/26280f201fdbc52b2470c4cc8e5ad6e9 to your computer and use it in GitHub Desktop.
Save agritheory/26280f201fdbc52b2470c4cc8e5ad6e9 to your computer and use it in GitHub Desktop.
Create a full clone of a Frappe app locally

Create a full clone of a Frappe app locally

Synthesized from several helpful stackoverflow responses and some trial and error. This is intended for use in a development or possibly staging environment.

bench get-app cloud_storage git@github.com:agritheory/cloud_storage.git --skip-assets

This will complete the default clone/install (but not build) of a Frappe app.

Let's confirm what we're working with is a shallow clone with only the latest commit on the default branch.

cd apps/cloud_storage
git branch
# version-14

Time for surgery. Remove the existing shallow clone folder from the app's folder,

# ~/frappe-bench/apps/cloud_storage
rm -rf .git
git clone --mirror git@github.com:agritheory/cloud_storage.git .git
git config --unset core.bare
git config receive.denyCurrentBranch updateInstead
git config --unset remote.origin.mirror
git reset --hard

Confirm this worked

# now test
# should show all branches from remote
git log 
# should show full commit history on default branch

Since this is focused on a development environment, it is appropriate to rename the remote from 'upstream' to 'origin'.

git remote rename upstream origin

Becasue this is based on the --mirror flag, some extra steps to get more normal fetch/pull behaviours are required. Edit /cloudstorage/.git/config:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = git@github.com:agritheory/cloud_storage.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[receive]
        denyCurrentBranch = updateInstead

This will allow you to fetch and/or pull onto open branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment