Skip to content

Git & GitHub Setup

chro uses Git for version control and GitHub for collaboration. This guide covers installation and SSH key setup for both platforms.

First, check if Git is already installed:

Terminal window
git --version

If Git is installed, you’ll see a version number. Otherwise, follow the installation instructions below.


Section titled “Option 1: Xcode Command Line Tools (Recommended)”

The easiest way to get Git on macOS:

Terminal window
xcode-select --install

A dialog will appear. Click “Install” and wait for completion.

If you have Homebrew installed:

Terminal window
brew install git
Terminal window
git --version # Should show git version 2.x.x

Using the Windows Package Manager:

Terminal window
winget install Git.Git

Note: Restart your terminal after installation.

  1. Download from git-scm.com
  2. Run the installer
  3. Use default settings (recommended for beginners)
  4. Ensure “Git from the command line and also from 3rd-party software” is selected

Open a new terminal/PowerShell window:

Terminal window
git --version

Configure your identity (required for commits):

Terminal window
git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Set default branch name to main:

Terminal window
git config --global init.defaultBranch main

Verify your configuration:

Terminal window
git config --list

If you don’t have a GitHub account:

  1. Go to github.com
  2. Click “Sign up”
  3. Follow the registration process
  4. Verify your email address

SSH keys provide secure, password-less authentication with GitHub.

macOS / Linux / Windows (Git Bash or WSL):

Terminal window
ssh-keygen -t ed25519 -C "[email protected]"

When prompted:

  • Press Enter to accept the default file location
  • Enter a passphrase (recommended) or press Enter for no passphrase

Windows (PowerShell):

Terminal window
ssh-keygen -t ed25519 -C "[email protected]"

macOS:

Terminal window
eval "$(ssh-agent -s)"

Add to ~/.ssh/config (create if it doesn’t exist):

Host github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519

Add your key:

Terminal window
ssh-add --apple-use-keychain ~/.ssh/id_ed25519

Windows (PowerShell - Run as Administrator):

Terminal window
# Start the ssh-agent service
Get-Service -Name ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
# Add your key
ssh-add $env:USERPROFILE\.ssh\id_ed25519

Linux / WSL:

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

1. Copy your public key:

macOS:

Terminal window
pbcopy < ~/.ssh/id_ed25519.pub

Windows (PowerShell):

Terminal window
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | Set-Clipboard

Linux:

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

2. Add to GitHub:

  1. Go to GitHub Settings > SSH Keys
  2. Click “New SSH key”
  3. Give it a descriptive title (e.g., “MacBook Pro 2024”)
  4. Paste your key into the “Key” field
  5. Click “Add SSH key”
Terminal window

You should see:

Hi username! You've successfully authenticated, but GitHub does not provide shell access.

Alternative: HTTPS with Personal Access Token

Section titled “Alternative: HTTPS with Personal Access Token”

If you prefer HTTPS over SSH:

  1. Go to GitHub Settings > Developer Settings > Personal Access Tokens
  2. Click “Generate new token (classic)”
  3. Give it a descriptive name
  4. Select scopes: repo (full control of private repositories)
  5. Click “Generate token”
  6. Copy the token immediately (you won’t see it again)

macOS:

Terminal window
git config --global credential.helper osxkeychain

Windows:

Terminal window
git config --global credential.helper wincred

When you first push/pull, enter your GitHub username and use the token as your password.


Test by cloning a repository:

Terminal window
# SSH (recommended)
git clone [email protected]:octocat/Hello-World.git
# Or HTTPS
git clone https://github.com/octocat/Hello-World.git

If successful, you’re ready to use Git with GitHub!


”Could not open a connection to your authentication agent”

Section titled “”Could not open a connection to your authentication agent””

Start the SSH agent:

Terminal window
eval "$(ssh-agent -s)"

Git asks for password on every push (HTTPS)

Section titled “Git asks for password on every push (HTTPS)”

Configure credential storage:

Terminal window
# macOS
git config --global credential.helper osxkeychain
# Windows
git config --global credential.helper wincred
# Linux
git config --global credential.helper store

Configure Git to handle line endings:

Terminal window
git config --global core.autocrlf true

Once Git and GitHub are configured, proceed to: