Git Commands Quick Reference Guide

By Paul Flanders ·

This quick reference guide covers essential Git commands for repository setup, staging, branching, merging, and working with remote repositories, making it a handy tool for developers to streamline their workflow.

Setup & Init

Command Description
git init Initialise a new local repository in the current directory
git clone <url> Clone a remote repository into a new local directory
git config --global user.name "Name" Set the name attached to all commits globally
git config --global user.email "email" Set the email address attached to all commits globally

Staging & Snapshots

Command Description
git status Show the working tree status — staged, unstaged, and untracked files
git add <file> Stage a specific file, ready to be included in the next commit
git add . Stage all changed and new files in the current directory
git reset <file> Unstage a file while preserving its changes in the working directory
git diff Show unstaged changes between the working directory and the index
git diff --staged Show changes staged for the next commit vs the last commit
git commit -m "message" Commit all staged changes with a descriptive message
git commit --amend Replace the last commit with a new one — useful for fixing messages or adding missed files

Branching & Merging

Command Description
git branch List all local branches; the current branch is highlighted
git branch <name> Create a new branch at the current commit
git checkout <branch> Switch to an existing branch
git checkout -b <name> Create a new branch and switch to it immediately
git switch <branch> Switch branches (modern alternative to checkout)
git merge <branch> Merge the specified branch into the current branch
git branch -d <name> Delete a branch that has already been merged
git rebase <branch> Reapply commits on top of another branch for a cleaner history

Remote Repositories

Command Description
git remote -v List all configured remote connections with their URLs
git remote add <name> <url> Add a new remote connection under a short alias
git fetch <remote> Download changes from the remote without merging them locally
git pull Fetch and merge changes from the tracked remote branch
git push <remote> <branch> Upload local commits to a remote branch
git push -u origin <branch> Push and set the upstream tracking branch in one step
git remote rm <name> Remove a remote connection by its alias

History & Inspection

Command Description
git log Show the full commit history for the current branch
git log --oneline Show a compact one-line summary of each commit
git log --graph Display the branch and merge history as an ASCII graph
git show <commit> Show the metadata and content changes of a specific commit
git blame <file> Show who last modified each line of a file and when

Undoing Changes

Command Description
git revert <commit> Create a new commit that undoes the changes from a specific commit
git reset --soft HEAD~1 Undo the last commit, keeping changes staged
git reset --hard HEAD~1 Undo the last commit and discard all changes permanently
git restore <file> Discard unstaged changes in a file, reverting to the last commit
git clean -fd Remove untracked files and directories from the working tree

Stashing

Command Description
git stash Temporarily shelve uncommitted changes to work on something else
git stash pop Re-apply the most recently stashed changes and remove them from the stash
git stash list List all stashed changesets
git stash drop Discard the most recent stash entry

person people found this useful.

Related

Knowledge base 10 Jun 2026

Personal Notebook in eLLM

The personal notebook in eLLM allows users to organise and store notes, images, and files in a private, searchable timeline. It ensures privacy by keeping contents visible only to the user, and it can be integrated with the assistant for personalised answers.

Knowledge base 9 Jun 2026

Organisation Skills in the eLLM Admin Console

The article explains how the eLLM Admin Console allows organisations to create and manage shared instruction sets called "organisation skills" to ensure consistent responses across teams. These skills can be customised, restricted to specific groups, and integrated with extern…

Knowledge base 9 Jun 2026

Tool Approvals in eLLM

The approvals page in eLLM allows administrators to review and approve or reject sensitive tool actions, ensuring human oversight. Tools set to auto-execute and personal user tools bypass this queue.

Expand 29 Jul 2026

How AI can support pupils with SEND

Explore how AI tools are aiding pupils with special educational needs and disabilities by simplifying text, breaking down tasks, and enhancing accessibility. Learn about the considerations schools should make before implementation.

Expand 29 Jul 2026

AI policy and practice in further education

Further education colleges need distinct AI policies due to their unique mix of vocational courses, diverse age groups, and specific funding and inspection requirements. This guidance highlights the importance of tailored AI approaches in FE settings.