Setup new github repo on the Pi:
-
Go to https://github.com/new and create a new private repo. The repo URL will be used below.
-
Go to https://github.com/settings/tokens and generate a new personal access token. Set the expiration to "No expiration" and select the first "Repo" checkbox then click Generate Token. When prompted for your github credentials below, enter your username and the token you just generated.
-
SSH into the Pi and run the following commands:
git config --global credential.helper store git config --global user.name "" git config --global user.email ""
cd ~/printer_data cd config git init git add . git commit -m "First commit" git remote add origin git remote -v git push --set-upstream origin master
- If you browse to your Github repo, you should see the backup.
Setup the macro:
-
Create a new folder called "git" in ~/printer_data/config/ (you can do this through Fluidd or Mainsail)
-
Upload backup_to_git_macro.cfg and backup_to_git.sh tp this new folder
-
SSH into the Pi and install "Shell Command" through Kiauh (Options: 4 then 9). When prompted to install the sample macro, just say No.
-
Edit printer.cfg and add this line near the top: [include git/*.cfg]
-
Restart the macro. You should now have a working "BACKUP_CFG" macro
#################################################################################
Cloning our config from the repo to the pi (Fresh OS Instalation)
1 - Set credentials
SSH into the Pi and run the following commands:
git config --global credential.helper store git config --global user.name "" git config --global user.email ""
2 - Exejute "cd ~/printer_data" 3 - A - Execute "rm -r config" (Delete whats is in our config folder) B - Execute "mv config configold" (To move your actual config folder to another) 4 - git clone config 5 - Now "cd config" then "ls -l" and you should see everything
################################################################################# This post documents how we can fix the problem of loose object is corrupt in git.
I run a Ubuntu guest system as a virtual machine in a Windows host with VirtualBox. Sometimes, especially when the machine is shutdown abruptly, a git directory will be damaged, showing the following error messages:
error: object file .git/objects/e1/ref is empty error: object file .git/objects/e1/ref is empty fatal: loose object e1ref (stored in .git/objects/e1/ref) is corrupt
The solution is:
find .git/objects/ -size 0 -exec rm -f {} ; git fetch origin
Then run git status, the repo should be functional again.