Bonsai_Tutorials/_Setup/Unlock with git-crypt.md

3.9 KiB

Unlock with git-crypt

The following are the steps unlock the repo in Linux and Mac and Windows.

These steps were created using ChatGPT, so there might be some errors.
If you run into errors, or if there's any missteps please log an issue here:
https://hub.openingdesign.com/OpeningDesign/Bonsai_Tutorials/issues
or create a pull request with the change. Thank you.

Linux and Mac

Steps to Unlock a Git-Crypt Repository on Linux

1. Open a Terminal {Linux, Mac) in the Repo Folder

Navigate to the top level of your project folder (where git-crypt is located):

cd /path/to/your/repo

2. Run the Unlock Command

If git-crypt is installed system-wide, simply run:

git-crypt unlock

If git-crypt is inside the repo and not globally installed, execute it directly:

./git-crypt unlock

3. If You Get the Error: no GPG secret key available to unlock this repository

Import the correct GPG private key (not the public key) :

gpg --import /path/to/private_key.asc

Example:

gpg --import ~/keys/secret_key.asc

📌 Make sure there are no spaces in the file path, or enclose it in quotes:

gpg --import "/home/user/My Keys/secret_key.asc"

Then, try unlocking again:

git-crypt unlock

4. If Unlocking Still Fails, Check Your Repo Path

  • Ensure the repository path does not contain special characters (#, @, !, &), as they can cause issues.
  • Try renaming the folder or cloning the repo to a different location.

5. If You Need to Specify a Key File Manually

git-crypt unlock /path/to/secretkey.asc

6. If You Get the Error: path/secretkey.asc: not a valid git-crypt key file

  • Ensure you're using the correct key file.
  • Check for special characters in the repo path and move it if necessary.

7. Verify That the Repo is Unlocked

git-crypt status

If successful, encrypted files should now be decrypted and accessible.

Let me know if you run into any issues! 🚀

Windows

Steps to Unlock a Git-Crypt Repository on Windows

1. Open a Command Line in the Repo Folder

Navigate to the top level of your project folder (where git-crypt.exe is located) and run the following. Try the Powershell approach first, and if that doesn't work, try the Git Bash approach. Make sure Kleopatra is running in the background.

  • PowerShell:

    • Hold down Shift + Right Click the project folder.

    • Select "Open PowerShell window here."

    • Run:

      ./git-crypt.exe unlock

  • Git Bash:

    • Right Click the project folder.

    • Select "Git Bash Here."

    • Run:

      ./git-crypt.exe unlock

The Following are a few troubleshooting steps, if the command above doesn't work...

  • If You Get the Error: no GPG secret key available to unlock this repository

    • You need to import the private key (not the public key) used for encryption:
      • gpg --import <path to private key file>
        • Example: gpg --import C:/keys/secret_key.asc
          • Make sure the file path has no spaces
          • Make sure it's your private key, and not your public key
      • then, try unlocking again:
        • ./git-crypt.exe unlock
  • If the above doesn't work, try to specify a key file manually...

    • Try: ./git-crypt.exe unlock path/to/secretkey.asc
      • If You Get the Error: path\secretkey.asc: not a valid git-crypt key file**

        • Make sure it's the correct path, and one without spaces.
        • Special characters (e.g., #, @, !, &) in the repo path can cause issues.