4 Setting Up GitHub
This section is for those new to GitHub or who need help with authentication. If you already have GitHub set up with SSH or a personal access token, skip to Installing Claude Code.
GitHub is where you’ll store your code, collaborate with others, and track changes to your projects. Claude Code works beautifully with git and GitHub—it can commit changes, create branches, and even open pull requests.
4.1 Why GitHub?
Even if you’re working alone, GitHub provides:
- Backup: Your code is safely stored in the cloud
- History: See every change ever made, revert mistakes
- Collaboration: Share with colleagues, get feedback
- Portfolio: Show your work to others
4.2 Step 1: Create a GitHub Account
- Go to github.com
- Click Sign Up
- Follow the prompts:
- Enter your email
- Create a password
- Choose a username (this is public and permanent-ish, choose wisely)
- Verify you’re human
- Verify your email
After creating your account, apply for the GitHub Student Developer Pack or GitHub for Education to get free private repositories and other benefits.
4.3 Step 2: Configure Git on Your Computer
Git is the version control software; GitHub is the website that hosts git repositories. Let’s configure git.
Open your terminal in VS Code and run:
# Set your name (use your real name)
git config --global user.name "Your Name"
# Set your email (use the same email as your GitHub account)
git config --global user.email "your.email@example.com"Verify the configuration:
git config --global --list4.4 Step 3: Authentication (The Tricky Part)
GitHub no longer accepts passwords for git operations. You need one of:
- GitHub CLI (Recommended - Easiest)
- SSH Keys (More technical but very reliable)
- Personal Access Token (Works but less convenient)
4.4.1 Option A: GitHub CLI (Recommended)
The GitHub CLI (gh) handles authentication automatically.
Install on Mac:
brew install ghIf you don’t have Homebrew, install it first:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Install on Windows:
winget install GitHub.cliInstall on Linux (Ubuntu/Debian):
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install ghAuthenticate:
gh auth loginFollow the prompts: 1. Select GitHub.com 2. Select HTTPS (recommended) 3. Select Login with a web browser 4. Copy the one-time code shown 5. Press Enter to open the browser 6. Paste the code and authorize
Verify it works:
gh auth statusYou should see: “Logged in to github.com as yourusername”
4.4.2 Option B: SSH Keys
SSH keys are a secure way to authenticate without entering credentials each time.
Generate a key:
ssh-keygen -t ed25519 -C "your.email@example.com"Press Enter to accept the default location. Optionally set a passphrase.
Start the SSH agent:
Mac/Linux:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Windows (Git Bash):
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Copy your public key:
Mac:
pbcopy < ~/.ssh/id_ed25519.pubWindows:
clip < ~/.ssh/id_ed25519.pubLinux:
cat ~/.ssh/id_ed25519.pub
# Then manually copy the outputAdd to GitHub: 1. Go to GitHub → Settings → SSH and GPG keys 2. Click New SSH Key 3. Paste your key 4. Give it a title like “My Laptop” 5. Click Add SSH Key
Test the connection:
ssh -T git@github.comYou should see: “Hi username! You’ve successfully authenticated…”
4.4.3 Option C: Personal Access Token (PAT)
If the above don’t work, you can use a PAT:
- Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click Generate new token (classic)
- Give it a name, set expiration
- Select scopes: at minimum
repo - Generate and copy the token immediately
When git asks for a password, paste this token instead.
Treat this token like a password. Store it in a password manager and never commit it to a repository.
To avoid entering the token repeatedly, use a credential helper:
Mac:
git config --global credential.helper osxkeychainWindows:
git config --global credential.helper managerLinux:
git config --global credential.helper store4.5 Step 4: Verify Everything Works
Let’s test by creating a repository:
cd ~/Projects
mkdir test-repo
cd test-repo
git init
echo "# Test" > README.md
git add README.md
git commit -m "Initial commit"Now create it on GitHub and push:
# If using GitHub CLI:
gh repo create test-repo --private --source=. --push
# If using SSH/PAT, create repo on github.com first, then:
git remote add origin git@github.com:yourusername/test-repo.git # SSH
# or
git remote add origin https://github.com/yourusername/test-repo.git # HTTPS
git push -u origin mainCheck github.com—you should see your repository!
4.6 Troubleshooting
4.6.1 “Permission denied (publickey)”
- Your SSH key isn’t set up correctly
- Try
ssh-add ~/.ssh/id_ed25519again - Make sure you added the .pub file (not the private key) to GitHub
4.6.2 “Support for password authentication was removed”
- You’re using a password instead of a token or SSH
- Set up one of the authentication methods above
4.6.3 “Repository not found”
- Check the URL is correct
- Make sure you have access to the repository
- If private, ensure you’re authenticated
4.6.4 “fatal: not a git repository”
- You’re not in a git repository
- Run
git initfirst, orcdto the right folder
4.7 Next Steps
GitHub is set up! Now let’s install Claude Code itself.
Continue to Installing Claude Code.