Git is the most popular version control system. It tracks changes to your code, lets you collaborate with others, and is essential for modern development.

Git Basics

Check Status

Ubuntu
git status

Shows which files have changed.

Stage Changes

Ubuntu
git add filename.txt

Stage a specific file.

Ubuntu
git add .

Stage all changed files.

Commit Changes

Ubuntu
git commit -m "Add login feature"

Save staged changes with a message.

View History

Ubuntu
git log --oneline

Shows commit history in a compact format.

Set Up SSH Keys for GitHub

SSH keys let you push/pull from GitHub without entering your password every time.

  1. Generate an SSH key:
    Ubuntu
    ssh-keygen -t ed25519 -C "[email protected]"

    Press Enter to accept the default location. You can add a passphrase or leave it empty.

  2. Start the SSH agent:
    Ubuntu
    eval "$(ssh-agent -s)"
  3. Add your key to the agent:
    Ubuntu
    ssh-add ~/.ssh/id_ed25519
  4. Copy your public key:
    Ubuntu
    cat ~/.ssh/id_ed25519.pub

    Copy the entire output (starts with ssh-ed25519).

  5. Add to GitHub:
    • Go to GitHub SSH Keys
    • Click "New SSH key"
    • Give it a title (e.g., "WSL Ubuntu")
    • Paste your public key
    • Click "Add SSH key"
  6. Test the connection:
    Ubuntu

    You should see "Hi username! You've successfully authenticated..."

Clone a Repository

To download a repository from GitHub:

Ubuntu
git clone [email protected]:username/repo.git

This creates a folder with the repository contents.

LazyGit - Visual Git Interface

LazyGit is a terminal UI for Git that makes complex operations visual and intuitive. The bootstrap script installed it for you.

Ubuntu
lazygit

Run this inside any Git repository to open the interface.

LazyGit Panels

Panel Purpose
Status Current branch and repo state
Files Changed files (stage with Space)
Branches Local and remote branches
Commits Commit history
Stash Stashed changes

Common LazyGit Keys

Key Action
Space Stage/unstage file
c Commit staged changes
p Push to remote
P Pull from remote
n New branch
Enter View diff/details
? Show all keybindings
q Quit
Press ? for help

LazyGit has many more features. Press ? in any panel to see all available keybindings for that context.