Set up Git on your new Linux PC

October 26, 2024
No Comments
2 min read

To set up Git on your new Linux PC, follow these steps:

  1. Install Git:
    Open your terminal and run the following command to install Git:
Bash
 sudo apt update
 sudo apt install git

(For other package managers like yum or dnf if you're on a different Linux distribution, replace apt with the appropriate manager.)

  1. Configure Git:
    After installing, configure your user name and email, which will be linked to your commits:
Bash
 git config --global user.name "Your Name"
 git config --global user.email "[email protected]"
  1. Generate SSH Key (optional but recommended):
    Generate an SSH key to securely connect to Git repositories without repeatedly entering your password:
Bash
 ssh-keygen -t rsa -b 4096 -C "[email protected]"

Save the key in the default location (usually ~/.ssh/id_rsa) and press Enter through each prompt.

  1. Add SSH Key to SSH Agent:
    Start the SSH agent and add your key:
Bash
 eval "$(ssh-agent -s)"
 ssh-add ~/.ssh/id_rsa
  1. Add SSH Key to GitHub/GitLab:
    Copy your public key to your clipboard:
Bash
 cat ~/.ssh/id_rsa.pub

Then paste it into your Git provider's SSH keys settings.

  1. Verify Setup:
    Test the connection with:
Bash
 ssh -T [email protected]

(Replace github.com with your Git provider if needed, like gitlab.com.)

You’re all set up to use Git on your new Linux PC!

©2025 Linux Bangla | Developed & Maintaind by Linux Bangla.