Ability to pull a private repository via Git
-
Hello!
I'd like to pull a private repository once a day, however, I currently need to retype the credentials every time. When I try to use git to store the credentials, I get the following error:
# git config --global credential.helper cache error: could not lock config file /root/.gitconfig: Read-only file system
Would it be possible to add a way to do this?
-
@FoksVHox On Cloudron , only the
/app/data
(persistent, part of app backup),/run
(runtime) and/tmp
(temporary, auto-cleaned up) directories are writable.So, you have to set the credential path to somewhere in
/app/data
usinggit config credential.helper 'store --file=/app/data/git_credentials'
. Important: You have to run this command in your git checkout! This is because it saves this info inside.git/config
.For example, my repo is
helloworld
. Then, I cd into it and:root@89cc2457-9d0a-4752-affb-c918fa4a90db:/app/data/helloworld# git config credential.helper 'store --file=/app/data/git_credentials' root@89cc2457-9d0a-4752-affb-c918fa4a90db:/app/data/helloworld# git fetch Username for 'https://git.cloudron.space': root Password for 'https://root@git.cloudron.space': root@89cc2457-9d0a-4752-affb-c918fa4a90db:/app/data/helloworld# git fetch
(the second command above ends up storing it in the file /app/data/git_credentials and the third command does not ask for password anymore).
-
Also, to automate the pull, put this in the app's cron:
* * * * * echo "==> Pulling" && cd /app/data/helloworld && git pull
Then, in the logs, you will see:
Mar 20 15:48:02 ==> Pulling Mar 20 15:48:02 From https://git.cloudron.space/root/helloworld Mar 20 15:48:02 8e9fa9a..6a79ead master -> origin/master Mar 20 15:48:02 Updating 8e9fa9a..6a79ead Mar 20 15:48:02 Fast-forward Mar 20 15:48:02 index.php | 3 ++- Mar 20 15:48:02 1 file changed, 2 insertions(+), 1 deletion(-)
It pulls every minute for testing, so you might want to adjust the cron pattern.