# Git Terminal Environment Setup Guide

> **Note:** These instructions are for a terminal or PowerShell environment.
> This guide was written for beginners setting up Git for the first time.
> All commands are cross-platform unless labeled with a specific OS.

## Make an Account
1. Go to GitHub and make an account

## Install Git on OS Terminal

### On Linux (Arch, Manjaro, EndeavourOS)
1. sudo pacman -S git

### On Linux (Ubuntu, Debian, Pop!)
1. sudo apt install git

### On Linux (Fedora)
1. sudo dnf install git

### On macOS
1. Install Homebrew from https://brew.sh
2. brew install git

### On Windows
Download the installer from https://git-scm.com/download/win and run it. During install, choose "Git Bash" so you have a Linux-style terminal.

## Verify the Install Worked
1. git --version

## Configure Your Identity
Let Git know who you are so it can label every change you make with your name and email.
1. git config --global user.name "Your Name"
2. git config --global user.email "your@email.com"

## Verify Your Name and Email is Setup
1. git config --global --list

## Generate a SSH Key
1. ssh-keygen -t ed25519 -C "your@email.com"
2. Save it in the Default Folder
3. Set a passphrase (optional)
4. Confirm the passphrase

## Grab the Contents of the SSH Key
1. cat ~/.ssh/id_ed25519.pub (copy the whole thing)

## Enter the Key into GitHub
1. Go to GitHub
2. Go to Settings
3. Find SSH and GPG Keys
4. Select New SSH Key
5. Name and enter your key in the appropriate field and save

## Verify that Git is Connected to Your Account
1. ssh -T git@github.com
2. If prompted say yes
3. Enter passphrase
4. You should get: Hi yourusername! You've successfully authenticated, but GitHub does not provide shell access.

## Connect your local repo to GitHub via SSH
1. git remote set-url origin git@github.com:yourusername/yourrepo.git
2. Verify it worked: git remote -v
3. Should show git@github.com not https://

## Setting Up Your Repo

### Starting From Scratch (New Project)
Use this if you are creating a brand new project that does not exist on GitHub yet.
1. Navigate to where you want your project to live
   cd /path/to/folder
2. Create a new folder
   mkdir yourproject
3. Go into it
   cd yourproject
4. Initialize a new git repo
   git init
5. Connect it to your GitHub repo and create the origin shortcut
   git remote add origin git@github.com:yourusername/yourrepo.git
6. Verify the connection
   git remote -v

### Cloning an Existing Repo (Already on GitHub)
Use this if the repo already exists on GitHub and you want to copy it to your machine.
1. Navigate to where you want the project to live
   cd /path/to/folder
2. Clone the repo
   git clone git@github.com:yourusername/yourrepo.git
   Note: git clone automatically creates the folder, pulls all files, and sets up 
   origin as a shortcut nickname pointing to your GitHub repo URL so you don't 
   have to type the full address every time you push or pull.
3. Go into the new folder
   cd yourrepo
4. Verify origin was set up automatically
   git remote -v
   Should show git@github.com not https://