applied · Level 2
Git for AI builders: commits, branches and pull requests
Track and share your work with Git, review every change before it lands, and keep AI-written code and secrets under control.

Start with the essentials
The short answer
Git is free version control software that records a project as a history of snapshots called commits. Work in small steps: read each change with git diff, stage what you mean with git add and commit it with a clear message. Use branches for experiments and merge them back, undo with git restore or git revert, keep secrets out, and share branches for review before they join main.
What you will learn
- You will be able to create a repository, stage changes and make small commits with clear messages.
- You will be able to read a diff and review every change, including AI-written ones, before you commit it.
- You will be able to create branches, merge them and resolve a merge conflict.
- You will be able to undo mistakes with git stash, git restore and git revert, and know which commands can lose work.
- You will be able to keep secrets out of your history, and know what to do first if one gets in.
- You will be able to share work through a remote and review a branch the way a pull request works.
Who it is for
Anyone who writes code, or builds with an AI assistant, and wants a safe record of their work: hobbyists, students, analysts and new developers. You should be able to open a terminal and type a command. No earlier Git experience is needed.
Before you start
- Basic terminal use: opening a terminal, changing folder with cd and running a command. No programming or Git experience is needed.
Keep learning
The complete workbook
This workbook takes you from your first commit to reviewing a colleague's branch the way a pull request works, all on your own computer. You will read diffs, commit in small steps, merge branches and resolve a conflict, undo mistakes safely and see why a deleted secret is still in the history. Throughout, you practise the habits that keep AI-written changes under your control.
- 01Git in plain words, and your first commitIn the workbook · 1 exercise
Git records a history of your project that you can read, compare and rewind. Install it and make your first commit.
- 02Read every change before you commit itIn the workbook · 1 exercise
A diff shows exactly what changed. Reading one before every commit keeps AI-written changes under your control.
- 03Branches, merges and conflictsIn the workbook · 1 exercise
A branch lets you try something without touching the main line. Merging brings it back, and sometimes Git asks you to decide.
- 04Undo safely when an assistant rewrote too muchIn the workbook · 1 exercise
Git gives you several ways back. Use the gentlest one that works, and know which commands lose work for good.
- 05Keep secrets out of your historyIn the workbook · 1 exercise
A secret committed once stays in the history after you delete the file. Prevention is cheap; cleaning up is not.
- 06Share work and review it like a pull requestIn the workbook · 1 exercise
A remote is another copy of the repository that people push to and fetch from. Here a local folder plays the hosting service, so nothing leaves your computer.
Also inside: a 9-point checklist, a glossary of 12 terms and 10 questions and answers to test yourself. 6 hands-on exercises, each with a worked answer at the back where the workbook gives one.
No login, no card, no account. Before the download we ask you to follow Mickai (two quick links). Free to download and use for personal learning, study groups and inside your own team. Please do not resell the workbooks or republish them as your own. Link people to trust-agent.ai instead.
Test yourself
Questions and answers
What is the difference between Git and GitHub?
Git is the version control software that runs on your computer. Hosting services, such as GitHub and GitLab, store Git repositories online and add features such as pull requests, reviews and automated checks. You can use Git fully without any hosting service, as this workbook does.
Do I need an account on a hosting service for this workbook?
No. Chapter 6 uses a bare repository in a folder on your computer as the shared copy, so you can practise pushing, fetching and reviewing without an account and without sending anything over the internet.
Which terminal should I use on Windows?
Git Bash, which comes with Git for Windows. It behaves like the macOS and Linux terminals, so every command in this workbook is the same. Other shells run the git commands too, but they may save files written with echo differently, which changes what Git shows.
What name and email should I give Git?
Ones you are happy to publish, because every commit records them and anyone who can see the repository can read them. Changing them later does not change earlier commits. Some hosting services offer a private no-reply address for this. In practice repositories, an invented identity is fine.
How often should I commit?
Whenever you finish one logical change. Small commits are easier to review, describe and undo. If an assistant made several unrelated changes, stage and commit them separately, and discard the ones you did not want.
I got a merge conflict. Have I broken something?
No. Git has paused the merge because both branches changed the same lines. Edit the file into the version you want, remove the marker lines, then add and commit it. If you would rather stop, git merge --abort tries to return you to where you were before the merge.
What is the difference between restore, revert and reset?
git restore puts files back from the staging area or a commit and does not change the history. git revert adds a new commit that undoes an earlier one, so it is safe on shared branches. git reset moves the branch itself and, with --hard, overwrites your files. Prefer restore and revert.
I committed a password or API key. What should I do?
Treat it as leaked. First revoke or rotate it with the service that issued it, then find out where the history has been pushed or cloned. Deleting the file in a new commit does not remove it from earlier snapshots, and rewriting history is a specialist job that cannot reach copies already made.
Is it safe to commit code that an AI assistant wrote?
Only after you have read it. Check git diff for changes you did not ask for, for secrets, and for anything that deletes or sends data. Commit in small pieces, say in the message what the assistant did and what you checked, and follow any policy your team has on AI-assisted work.
Why are my commit IDs different from the ones in this workbook?
A commit's ID is a checksum of its contents, which include the author's name and email and the time it was made. Your name, email and times differ, so your IDs will too. The messages, files and diffs should match.
When you have finished
Get your certificate of completion
Type your name and download a certificate for this workbook as a PDF, ready to print or to add to LinkedIn. It is made on your own device, so your name is never sent to us. It is a self-declared certificate, not an accredited qualification.
Learn the language
Key terms
- Repository
- A project folder together with its full history, which Git keeps in a hidden
.gitfolder. - Commit
- A saved snapshot of the project with a message, an author and a time, identified by a checksum.
- Working tree
- The files you can see and edit in the project folder.
- Staging area
- Also called the index: the changes that will go into the next commit, chosen with
git add. - Diff
- A line-by-line comparison of two versions, with
-for removed lines and+for added ones. - Branch
- A movable label on a commit that lets you work on something without changing
main.
6 of the workbook's 12 terms. The complete glossary is in the workbook.
Follow the evidence
Sources and checks
Facts last checked: .
Examples in this workbook were run on: Git 2.54.0.windows.1 in Git Bash (GNU bash 5.3.9) on Windows 11 Pro 10.0.26200, with an empty global Git configuration; re-run by the checker with no global or system configuration, both captured and in a pseudo-terminal, and again with core.autocrlf=true; chapter 1 also tried in Windows PowerShell 5.1.26100.9549 (2026-09-26).
These workbooks use AI assistance. See how the workbooks are made.
- Pro Git 1.1: About Version ControlPro Git, 2nd edition (git-scm.com)
- Pro Git 1.3: What is Git?Pro Git, 2nd edition (git-scm.com)
- Pro Git 1.5: Installing GitPro Git, 2nd edition (git-scm.com)
- Pro Git 1.6: First-Time Git SetupPro Git, 2nd edition (git-scm.com)
- Pro Git 2.2: Recording Changes to the RepositoryPro Git, 2nd edition (git-scm.com)
- Pro Git 2.4: Undoing ThingsPro Git, 2nd edition (git-scm.com)
- Pro Git 2.5: Working with RemotesPro Git, 2nd edition (git-scm.com)
- Pro Git 3.1: Branches in a NutshellPro Git, 2nd edition (git-scm.com)
- Pro Git 3.2: Basic Branching and MergingPro Git, 2nd edition (git-scm.com)
- Pro Git 4.2: Getting Git on a Server (bare repositories)Pro Git, 2nd edition (git-scm.com)
- Pro Git 5.2: Contributing to a Project (commit guidelines)Pro Git, 2nd edition (git-scm.com)
- Pro Git 7.3: Stashing and CleaningPro Git, 2nd edition (git-scm.com)
- Pro Git 10.2: Git ObjectsPro Git, 2nd edition (git-scm.com)
- Git home page (free and open source)Git project (git-scm.com)
- Install Git on WindowsGit project (git-scm.com)
- Install Git on macOSGit project (git-scm.com)
- Install Git on LinuxGit project (git-scm.com)
- Git for Windows (Git BASH)Git for Windows project
- about_Character_Encoding (redirection in Windows PowerShell 5.1)Microsoft Learn
- git-init referenceGit project (git-scm.com)
- git-config referenceGit project (git-scm.com)
- git-status reference (short format)Git project (git-scm.com)
- git-diff referenceGit project (git-scm.com)
- git-commit reference (commit message discussion)Git project (git-scm.com)
- git-log reference (-S)Git project (git-scm.com)
- git-switch referenceGit project (git-scm.com)
- git-merge reference (fast-forward, conflicts, --abort)Git project (git-scm.com)
- git-restore referenceGit project (git-scm.com)
- git-stash referenceGit project (git-scm.com)
- git-revert referenceGit project (git-scm.com)
- git-reset reference (--hard)Git project (git-scm.com)
- git-push reference (--force)Git project (git-scm.com)
- git-pull referenceGit project (git-scm.com)
- gitignore referenceGit project (git-scm.com)
- git-check-ignore referenceGit project (git-scm.com)
- gitrevisions reference (ranges and revision names)Git project (git-scm.com)
- git-var reference (default editor)Git project (git-scm.com)
- Pull requestsGitHub Docs
- Pull request reviewsGitHub Docs
- Merge requestsGitLab Docs
- Setting your commit email addressGitHub Docs
- Removing sensitive data from a repositoryGitHub Docs
- Secret scanningGitHub Docs
- Push protectionGitHub Docs
- Secret detectionGitLab Docs
- Secrets Management Cheat SheetOWASP Cheat Sheet Series
- Secure development and deployment guidance: Protect your code repositoryNational Cyber Security Centre (UK)
Created by Mickarle Wagstaff-Irons - Micky Irons with the Mickai team. Published by Mickai LTD. Last updated 26 September 2026.
NextKeep going
Where to go next
Recommended for you
Build your first app with an AI coding assistant
Build a small bill-splitting web page with any AI coding assistant while staying in control: brief it, build in steps, review the code, test edge cases and keep safe copies.
Recommended for you
Python: from first script to a useful automation
A complete beginner's route from installing Python to a tested, dry-run-first tool that sorts and reports on a folder, using only what comes with Python.
Recommended for you
Build and launch a website with AI
Plan a simple site, have AI write the HTML and CSS, understand and check the code, then publish it free with HTTPS and sound search, accessibility and privacy basics.