4  Setting Up GitHub

Branch Section

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

  1. Go to github.com
  2. Click Sign Up
  3. 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
Academic Benefits

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 --list

4.4 Step 3: Authentication (The Tricky Part)

GitHub no longer accepts passwords for git operations. You need one of:

  1. GitHub CLI (Recommended - Easiest)
  2. SSH Keys (More technical but very reliable)
  3. Personal Access Token (Works but less convenient)

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_ed25519

Windows (Git Bash):

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

Copy your public key:

Mac:

pbcopy < ~/.ssh/id_ed25519.pub

Windows:

clip < ~/.ssh/id_ed25519.pub

Linux:

cat ~/.ssh/id_ed25519.pub
# Then manually copy the output

Add 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.com

You 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:

  1. Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
  2. Click Generate new token (classic)
  3. Give it a name, set expiration
  4. Select scopes: at minimum repo
  5. Generate and copy the token immediately

When git asks for a password, paste this token instead.

Token Security

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 osxkeychain

Windows:

git config --global credential.helper manager

Linux:

git config --global credential.helper store

4.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 main

Check 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_ed25519 again
  • 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 init first, or cd to the right folder

4.7 Next Steps

GitHub is set up! Now let’s install Claude Code itself.

Continue to Installing Claude Code.