Configurations
Global Configurations
Global git configurations are done with the flag --global
.
Username and Email
If in <user-name>
you need a spaced name, make sure to wrap it in double quotes. ("User Name"
)
Keep in mind that global user configurations do not stop you from impersonating someone else.
Always configure your GPG Signatures, that will be used in Commits, PRs, etc..
Signinkey
Always configure Git to sign Commits, PRs, etc with your GPG Public key.
To configure the Public GPG key for Git to use for its commands.
This key will be used to verfify that Git username is the one from GitHub.
Aside from this configuration you will need to also configure a System Environment Variable.
If it works, your signed commits, etc will ask for your Private Key's Password.
Editor to use
To change the default editor that git uses for its commands.
Using GPG Signatures
You should use GPG keys to sign your commits, PRs, and more.
This is a more secure way to verify that action you make are your own so that others cannot impersonate you.
Using VSCode in WSL2
Failure to complete this step will produce errors and failure in using the GPG keys, if using VSCode's to Commit, Push, etc.
GPG4Win
will recognize GPG keys created, in WSL Ubuntu, before it was installed.
There is no need to re-create the GPG keys.
Install
GPG4Win
on the Windows side.Then inside Ubuntu make sure GPG is installed
Edit/create this file in Ubuntu:
Force restart the gpg agent to apply the changes.
Make sure to add in VSCode.
Check existent Keys
The keys are maintained in /home/user/.gnupg
.
Run the command on your machine that you will be using git.
If the command returns nothing, means that there are no generated keys on your system. (If the
/.gnupg
folder doesn't exist it might say that it was created)
Create a Private Key
Run the command and pick the default key (RSA and RSA).
Choose the key size to be the longest (4096 bits).
The validity time can be any you want.
In user ID to identify your key section
"Real Name" is the same
user.name
you configured in Git. (Which can be your GitHub username or your full name)"Email Address" will also be the same
user.email
configured in Git.
For last, it will request a password so that you can access your keys. (If running on WSL the password window should be opening from Windows)
Get Private Key ID
To find the <private-key-ID>
run the command to show existing keys:
The <private-key-ID>
will be the one after sec rsa4096/
.
Get the Public Key
Add Public Key to GitHub
Copy the "Public Key Block" from the first command to GitHub at https://github.com/settings/gpg/new.
Last updated