Misc Git Notes¶
Table of Contents¶
Plain GPG Protected Credential Helper¶
Using GPG authentication (HTTPS) with git is not as straightforward as using
SSH authentication.
You have to set up a credential helper and then set up a password manager.
Using GPG for Github Authentication¶
-
If you're using HTTP/HTTPS authentication, and you want to authenticate with
your GPG key, you can set up a credential helper -
Set git to use gpg
git config --global credential.credentialStore gpg
Generate a New GPG Key¶
First, you'll need to generate a GPG key before you can add it to Github.
- Run the command to generate a new key:
gpg --full-generate-key
- Specify the type. RSA (default) is good.
- Specify key size (4096)
- Enter when key will expire
- This is optional. You can leave it blank if you don't want the key to expire.
- Verify
- Enter your user info
- Note: Use the email associated with your GitHub account.
- Set a password
Add the New GPG Key to Github¶
-
List your GPG keys to find the Key ID.
gpg --list-secret-keys --keyid-format=long
- You will see an output that looks like this:
/home/user/.gnupg/secring.gpg ----------------------------- sec 4096R/<Your-Key-ID> 2021-01-01 [expires: 2024-01-01] # or sec rsa4096/<Your-Key-ID> 2021-01-01 [expires: 2024-01-01]
- Take
<Your-Key-ID>
. This is your Key ID.
- You will see an output that looks like this:
-
Add the public key to GH account.
- Export your public key using your Key ID:
gpg --armor --export <Your-Key-ID>
- If you want, redirect to a file (
> gpg_key.txt
) for easy copypasta.
- If you want, redirect to a file (
- On Github, go to Profile -> Settings -> SSH and GPG keys.
- Select "Add GPG Key", and paste your public key.
- Export your public key using your Key ID:
Signing Commits with GPG¶
- Configure Git to use your GPG key.
- Set your
signingkey
in your.gitconfig
:
git config --global user.signingkey <Your-Key-ID>
- To sign all commits by default in any local repository on your computer:
git config --global commit.gpgsign true
- Set your
Other Git Encryption Solutions:¶
- SSH with
ssh-keygen
git-remote-gcrypt
git-secret
-
git-crypt
-
BlackBox by StackOverflow
Git Commit Message Conventions¶
[type]: [description]
[body]
Where:
-
[type]
: Indicates the type of the commit. It should be one of the following:- feat: A new feature or functionality added.
- fix: A bug fix or error correction.
- docs: Documentation updates or changes.
- style: Changes to code formatting, indentation, etc.
- refactor: Code refactoring or restructuring without adding new features or fixing bugs.
- test: Adding or updating tests.
- chore: Maintenance tasks or other miscellaneous changes.
-
[description]
: A brief and concise description of the change made in the commit.- It should start with a capitalized verb and should not exceed 50 characters.
-
[body]
(optional): A more detailed description of the changes made in the commit.- This part is optional but can be useful for providing additional context or information about the changes.