Install and Configure Git
Ubuntu
Install Git
-
Update the package index:
sudo apt update -
Install Git:
sudo apt install git -
Verify the installation:
git --version
Configure Git
-
Set your username:
git config --global user.name "Your Name" -
Set your email:
git config --global user.email "your.email@example.com" -
View the configuration:
git config --list -
Optional: Set the default text editor:
git config --global core.editor vim -
Optional: Set an alias:
git config --global alias.gs status
Rocky Linux
Install Git
-
Update the package index:
sudo dnf update -
Install Git:
sudo dnf install git -
Verify the installation:
git --version
Configure Git
-
Set your username:
git config --global user.name "Your Name" -
Set your email:
git config --global user.email "your.email@example.com" -
View the configuration:
git config --list -
Optional: Set the default text editor:
git config --global core.editor vim -
Optional: Set an alias:
git config --global alias.gs status
Configure SSH Keys
Generate an SSH Key
Generate an SSH key:
ssh-keygen
Press Enter through all the prompts, and the key pair will be generated. The key pair is typically stored in ~/.ssh.
Copy the Public Key and Add It to Your Git Service
-
Copy the public key content:
cat ~/.ssh/id_rsa.pub -
Add the public key to your Git service (e.g., GitHub, GitLab, etc.) in the SSH key settings.