- Basic understanding of command-line interface (CLI).
- A GitHub account (sign up at GitHub).
-
Windows:
- Download the installer from git-scm.com.
- Run the installer and follow the prompts.
- Open Git Bash (installed with Git) to use Git commands.
-
Mac:
- Open the Terminal.
- Install Homebrew if not already installed:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Git:
brew install git
-
Linux:
- Use the package manager specific to your distribution.
- For Debian/Ubuntu:
sudo apt-get install git
- For Fedora:
sudo dnf install git
Set your username and email in Git:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
SSH keys allow you to securely connect to GitHub without needing to enter your username and password each time.
-
Generate a new SSH key:
- Open your terminal (or Git Bash on Windows).
- Generate the SSH key:
ssh-keygen -t ed25519 -C "[email protected]"
- When prompted, accept the default file location and enter a passphrase for added security.
If you're using an older system that doesn't support
ed25519
, usersa
instead:ssh-keygen -t rsa -b 4096 -C "[email protected]"
-
Copy the SSH key to your clipboard:
- On Linux or Mac:
For
cat ~/.ssh/id_ed25519.pub | pbcopy
rsa
:cat ~/.ssh/id_rsa.pub | pbcopy
- On Windows (Git Bash):
For
clip < ~/.ssh/id_ed25519.pub
rsa
:clip < ~/.ssh/id_rsa.pub
- On Linux or Mac:
-
Add the SSH key to your GitHub account:
- Go to GitHub and log in.
- In the upper-right corner, click on your profile photo, then click Settings.
- In the user settings sidebar, click SSH and GPG keys.
- Click New SSH key.
- Provide a descriptive title for the new key and paste your SSH key into the "Key" field.
- Click Add SSH key.
To ensure everything is set up correctly, test the connection to GitHub:
ssh -T [email protected]
You should see a message like this:
Hi yourusername! You've successfully authenticated, but GitHub does not provide shell access.
Now that your laptop is connected to GitHub via SSH, you can clone repositories:
-
Navigate to the directory where you want to clone the repository:
cd /path/to/your/directory
-
Clone the repository using SSH:
- Go to the repository page on GitHub.
- Click the green Code button, select SSH, and copy the SSH URL.
- Clone the repository:
git clone [email protected]:username/repository.git
You’ve successfully connected your laptop with GitHub using SSH. You can now clone repositories, push changes, and collaborate securely without entering your credentials each time.