Skip to main content
Foundations

A Creative Technologist's Guide to GitHub & AI-Powered Workflows

17 Modules
Chapter 13: Chapter 7: Reference Cheat Sheet76%

Chapter 7: Reference Cheat Sheet

This chapter provides a quick reference for some of the most common Git commands you'll use. Keep this handy as you work on your projects. This is based on the cheat sheet from the original workshop.md.

Essential Git Commands

Configuration (Usually done once)

Set your name and email (important for commit attribution):

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Set the default branch name for new repositories to main:

git config --global init.defaultBranch main

Starting a New Local Project

Create a new directory, navigate into it, and initialise a Git repository:

mkdir my-new-project
cd my-new-project
git init

Connecting a Local Repository to a Remote (e.g., GitHub)

If you've created a new repository on GitHub and want to link your local project to it:

# (Assumes you've already run 'git init' locally)
# Replace URL with your actual GitHub repository URL
git remote add origin https://github.com/yourusername/your-repository-name.git

To push your initial main branch to the remote and set it to track:

git push -u origin main

Everyday Workflow

Check the status of your files (what's changed, what's staged):

git status

Stage all changes in the current directory and subdirectories:

git add .

Stage changes in a specific file:

git add path/to/your/file.txt

Commit staged changes with a descriptive message:

git commit -m "Your descriptive commit message"

Push your committed changes from your local branch to the remote repository:

git push

Pull changes from the remote repository to your local branch (fetches and merges):

git pull

Branching

List all local branches (current branch is marked with *):

git branch

Create a new branch:

git branch new-feature-branch

Switch to an existing branch:

git checkout existing-branch-name

Create a new branch and switch to it in one command:

git checkout -b new-feature-branch

Merge changes from another branch into your current branch:

# (First, make sure you are on the branch you want to merge INTO, e.g., 'main')
# git checkout main
git merge other-branch-name

Delete a local branch (usually after it has been merged):

git branch -d branch-to-delete

Force delete a local branch (if it hasn't been merged, use with caution):

git branch -D branch-to-delete

Viewing History

View commit history (basic):

git log

View commit history in a compact, graphed format:

git log --oneline --graph --decorate --all

Undoing Things (Use with care, especially reset on shared history)

Unstage a file (remove from staging area, keep changes in working directory):

git reset HEAD path/to/your/file.txt
# Or, for newer Git versions:
git restore --staged path/to/your/file.txt

Discard changes in a specific file in your working directory (revert to last commit):

git checkout -- path/to/your/file.txt
# Or, for newer Git versions:
git restore path/to/your/file.txt

Amend the last commit (change message, add more files):

# (Stage any additional files with 'git add' first if needed)
git commit --amend -m "New or corrected commit message"

Claude Code Quick Reference

CommandWhat it Does
claudeLaunch Claude Code in the current directory
/helpShow all available commands
/fastSwitch to a faster, cheaper model
/clearClear conversation and start fresh
/compactSummarise conversation to save context
/initCreate a CLAUDE.md file for your project

Context Management Tips

  • Use /compact when the conversation gets long or the AI starts losing track.
  • Use /clear when switching to a completely different task.
  • Use /fast for quick, routine questions to save costs.
  • Keep your CLAUDE.md file concise and up to date.

This cheat sheet covers many of the day-to-day commands. For more advanced scenarios or detailed explanations, refer to the official Git documentation or use git help <command>.


Next: Chapter 8: Advanced Typesetting: LaTeX with WSL2, TeXLive, and VS Code