English | 简体中文
Automatically encrypt/decrypt sensitive files in Git repositories. https://git-cryptx.201945.xyz
- 🔒 Transparent file encryption/decryption
- 🔄 Seamless Git workflow integration
- 🎯 Precise file pattern matching
- 👥 Team collaboration support
- 💻 Cross-platform support
To compile the project, use the following command:
cargo build --releaseAfter building, make sure to add the binary to your system's PATH permanently:
-
Linux/macOS: Add the following line to your
~/.bashrc,~/.bash_profile, or~/.zshrcfile:export PATH="$PATH:/path/to/your/project/target/release"
Then, run:
source ~/.bashrc # or source ~/.bash_profile or source ~/.zshrc
-
Windows:
- Search for "Environment Variables" in the Start menu.
- Click on "Environment Variables".
- Under "System variables", find the
Pathvariable and click "Edit". - Add the path to your project's
target/releasedirectory. - Click "OK" to save changes.
For macOS users, you can install git-cryptx using Homebrew:
brew tap ChrisHyperFunc/brew
brew install git-cryptx
brew upgrade git-cryptx-
Initialize repository: git-cryptx init
-
Set encryption key: git-cryptx set-key
-
Configure files to encrypt (edit .gitattributes and the file must not be encrypted):
example.secret filter=git-cryptx diff=git-cryptx
*.secret filter=git-cryptx diff=git-cryptx
config/*.key filter=git-cryptx diff=git-cryptx
sensitive/* filter=git-cryptx diff=git-cryptx
sub_tree_directories/** filter=git-cryptx diff=git-cryptx
If necessary:
.gitattributes !filter !diff
init: Initialize git-cryptxset-key <key>: Add encryption keyrm-key: Remove encryption keystatus: Show encryption status
git-cryptx uses Git's filter mechanism to automatically encrypt and decrypt files:
- When files are added to Git, the clean filter encrypts content
- When files are checked out, the smudge filter decrypts content
- Files remain in plaintext in working directory
- Files remain encrypted in Git repository
- Uses AES-256-GCM for encryption
- Keys stored in .git/cryptx directory
- Supports file integrity verification
- Encrypted files marked with magic number
Q: How to share keys with team members? A: Share the .git/cryptx/keys/global_ase_key file through a secure channel.
Q: How to view differences in encrypted files? A: git-cryptx supports viewing plaintext differences directly using regular git diff.
When a new team member joins the project, follow these steps:
- Clone the repository:
git clone <repository-url>- Initialize git-cryptx:
git-cryptx init-
Obtain the key file from other team members:
- Get the
.git/cryptx/keys/global_ase_keyfile - Place it in the same location in your local repository
- Or git-cryptx set-key
- Get the
-
Check configuration status:
git-cryptx status- Update working directory files:
# Clean working directory
git clean -fd
# Checkout files to trigger decryption
git checkout .Important notes:
- Transfer the key file through secure channels (encrypted email, secure messaging, etc.)
- Never commit the key file to the Git repository
- Each cloned repository needs its own key configuration
- If files appear encrypted, the key is not properly configured
Pull requests and issues are welcome.
MIT License