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.

By Mickarle Wagstaff-Irons - Micky Irons

  • Level 2Getting going
  • 125 min
  • 6 chapters
  • Free PDF, no account
The Assemblyapplied / 02

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.

  1. 01
    Git in plain words, and your first commit

    Git records a history of your project that you can read, compare and rewind. Install it and make your first commit.

    In the workbook · 1 exercise
  2. 02
    Read every change before you commit it

    A diff shows exactly what changed. Reading one before every commit keeps AI-written changes under your control.

    In the workbook · 1 exercise
  3. 03
    Branches, merges and conflicts

    A branch lets you try something without touching the main line. Merging brings it back, and sometimes Git asks you to decide.

    In the workbook · 1 exercise
  4. 04
    Undo safely when an assistant rewrote too much

    Git gives you several ways back. Use the gentlest one that works, and know which commands lose work for good.

    In the workbook · 1 exercise
  5. 05
    Keep secrets out of your history

    A secret committed once stays in the history after you delete the file. Prevention is cheap; cleaning up is not.

    In the workbook · 1 exercise
  6. 06
    Share work and review it like a pull request

    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.

    In the workbook · 1 exercise

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 .git folder.
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.

  1. Pro Git 1.1: About Version ControlPro Git, 2nd edition (git-scm.com)
  2. Pro Git 1.3: What is Git?Pro Git, 2nd edition (git-scm.com)
  3. Pro Git 1.5: Installing GitPro Git, 2nd edition (git-scm.com)
  4. Pro Git 1.6: First-Time Git SetupPro Git, 2nd edition (git-scm.com)
  5. Pro Git 2.2: Recording Changes to the RepositoryPro Git, 2nd edition (git-scm.com)
  6. Pro Git 2.4: Undoing ThingsPro Git, 2nd edition (git-scm.com)
  7. Pro Git 2.5: Working with RemotesPro Git, 2nd edition (git-scm.com)
  8. Pro Git 3.1: Branches in a NutshellPro Git, 2nd edition (git-scm.com)
  9. Pro Git 3.2: Basic Branching and MergingPro Git, 2nd edition (git-scm.com)
  10. Pro Git 4.2: Getting Git on a Server (bare repositories)Pro Git, 2nd edition (git-scm.com)
  11. Pro Git 5.2: Contributing to a Project (commit guidelines)Pro Git, 2nd edition (git-scm.com)
  12. Pro Git 7.3: Stashing and CleaningPro Git, 2nd edition (git-scm.com)
  13. Pro Git 10.2: Git ObjectsPro Git, 2nd edition (git-scm.com)
  14. Git home page (free and open source)Git project (git-scm.com)
  15. Install Git on WindowsGit project (git-scm.com)
  16. Install Git on macOSGit project (git-scm.com)
  17. Install Git on LinuxGit project (git-scm.com)
  18. Git for Windows (Git BASH)Git for Windows project
  19. about_Character_Encoding (redirection in Windows PowerShell 5.1)Microsoft Learn
  20. git-init referenceGit project (git-scm.com)
  21. git-config referenceGit project (git-scm.com)
  22. git-status reference (short format)Git project (git-scm.com)
  23. git-diff referenceGit project (git-scm.com)
  24. git-commit reference (commit message discussion)Git project (git-scm.com)
  25. git-log reference (-S)Git project (git-scm.com)
  26. git-switch referenceGit project (git-scm.com)
  27. git-merge reference (fast-forward, conflicts, --abort)Git project (git-scm.com)
  28. git-restore referenceGit project (git-scm.com)
  29. git-stash referenceGit project (git-scm.com)
  30. git-revert referenceGit project (git-scm.com)
  31. git-reset reference (--hard)Git project (git-scm.com)
  32. git-push reference (--force)Git project (git-scm.com)
  33. git-pull referenceGit project (git-scm.com)
  34. gitignore referenceGit project (git-scm.com)
  35. git-check-ignore referenceGit project (git-scm.com)
  36. gitrevisions reference (ranges and revision names)Git project (git-scm.com)
  37. git-var reference (default editor)Git project (git-scm.com)
  38. Pull requestsGitHub Docs
  39. Pull request reviewsGitHub Docs
  40. Merge requestsGitLab Docs
  41. Setting your commit email addressGitHub Docs
  42. Removing sensitive data from a repositoryGitHub Docs
  43. Secret scanningGitHub Docs
  44. Push protectionGitHub Docs
  45. Secret detectionGitLab Docs
  46. Secrets Management Cheat SheetOWASP Cheat Sheet Series
  47. 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