This guide explains two ways to authenticate with GitHub:
- SSH (recommended for long-term use)
- HTTPS
SSH uses a key pair and avoids password prompts.
Git Bash often handles SSH keys automatically. If cloning works without asking for a password, you do not need to start the SSH agent or add the key manually (STEP 2).
STEP 1: Generate an SSH Key
ssh-keygen -t ed25519 -C "your_email@example.com"Press Enter to accept defaults.
STEP 2: Start SSH Agent and Add Key
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519STEP 3: Add Public Key to GitHub
cat ~/.ssh/id_ed25519.pub- Copy the output
- GitHub → Settings → SSH and GPG keys
- New SSH key → Paste → Save
STEP 4: Clone Using SSH
git clone git@github.com:USERNAME/REPOSITORY.gitDONE.
HTTPS uses your GitHub username and a Personal Access Token.
STEP 1: Create a GitHub Token
- Go to GitHub → Settings
- Developer settings → Personal access tokens
- Create a Fine-grained token
- Give access to repositories
- Copy the token (you will not see it again)
STEP 2: Clone the Repository
git clone https://github.com/USERNAME/REPOSITORY.gitSTEP 3: Authenticate When prompted:
- Username: your GitHub username
- Password: paste the token
DONE.