Tutorials / Claude Code: AI-Assisted Coding from First Prompt to Daily Workflow / Git workflows: branches, commits and pull request descriptions

Git workflows: branches, commits and pull request descriptions

10 min read text
Course contents (20 lessons)
  1. Meet Claude Code
  2. What Claude Code is and how it differs from a chat window
  3. Installing Claude Code and signing in
  4. Your first session: explore, ask, change
  5. Asking well and staying in control
  6. Asking for changes: context, goal, constraints and acceptance criteria
  7. Reading and approving edits
  8. Permission modes: how much freedom to give
  9. Project memory and slash commands
  10. CLAUDE.md: teaching the tool about your project
  11. Slash commands and custom commands
  12. Everyday coding workflows
  13. The plan-first workflow
  14. Understanding unfamiliar code
  15. Debugging with Claude Code
  16. Refactoring safely
  17. Writing tests with Claude Code
  18. Git, small changes, cost and security
  19. Git workflows: branches, commits and pull request descriptions
  20. Keeping changes small and reviewable
  21. Context and cost awareness
  22. Security habits: secrets, commands and untrusted input
  23. Extending the tool, teamwork and a final project
  24. Hooks and MCP servers explained
  25. Team practices for AI-assisted coding
  26. Final project: building a small app step by step

Git is your safety system

Everything in this course gets easier and safer when your work is in git. The tool edits files. Git tells you exactly what changed and lets you step back. Treat the two as a pair.

Work on a branch

Create a branch for each task before you start, so that the main branch stays clean.

git switch main
git pull
git switch -c feature/overdue-invoice-emails

You can ask the tool to do these steps, and it will use git commands, which you can read before approving. I often type them myself, because it is quick and I stay aware of where I am.

Commit in small steps

After each step of the plan, once tests pass and you have read the diff, commit. Small commits make review easy and give you many points to return to.

Look at the staged changes with git diff --staged and write a commit message. Use the imperative mood, a subject line under 60 characters, then a short body explaining why the change was made, not what, since the diff shows what. Match the style of the last 10 commits in git log. Show me the message and do not commit yet.

Why it works

The tool reads the staged diff, not the whole working tree, so the message describes exactly what will be committed. Pointing to recent history makes the style match your team's. "Do not commit yet" keeps the final decision with you. Commit messages written this way tend to be clearer than my own tired ones, but I still correct them when the "why" is wrong, because the tool can only guess the reasons.

Stage with care

Do not use git add . on autopilot. Review what is untracked and modified, and stage the files that belong to this change.

git status
git add src/Invoices/OverdueNotifier.cs tests/Invoices/OverdueNotifierTests.cs
git diff --staged

This protects you from committing a stray debug file, a local settings file or a log. If a secret ever ends up in a commit, treat it as exposed, and rotate it. Removing it from later commits does not remove it from history.

Pull request descriptions

Write a pull request description for the changes on this branch compared with main. Use this structure:
## Summary (2-3 sentences)
## Changes (bullets, grouped by area)
## How to test (numbered steps a reviewer can follow)
## Risks and rollback (what could go wrong, how to undo)
Base it on the actual diff and commit messages. Do not mention anything you cannot see in them.

"Do not mention anything you cannot see" reduces made-up claims such as "this also improves performance". Then read the draft and correct it. A reviewer will trust the text only if it is true.

Using the platform's command-line tools

If you use a command-line tool for your hosting platform, the assistant can run it to open a pull request or read comments. The commands and permissions depend on that tool and on your setup, so check its documentation. Always read the command before approving, since this one publishes things to a shared place.

Responding to review comments

Here is a review comment on OverdueNotifier.cs line 42: "This will send duplicate emails if the job runs twice." Check whether the comment is right. If it is, propose the smallest fix and a test that would have caught it. If it is wrong, explain why so I can reply.

Notice the "if it is wrong" part. Reviewers are sometimes mistaken, and a tool that always agrees is not helping. Ask for evidence either way.

Be honest about AI help

Follow your team's policy on disclosing AI assistance. In many teams it is fine to use it, but you are the author and you must understand every line you submit. "The AI wrote it" is not an answer to a reviewer's question. Be able to explain the change.

Things not to let the tool do without a close look

  • Force-pushing, resetting hard, deleting branches or rewriting history.
  • Pushing to shared branches such as main.
  • Amending commits that are already pushed.

Decline these unless you asked for them and know exactly what they will do.

The common mistake

The common mistake is committing everything at the end as one huge "Implement feature" commit. When something breaks, you cannot find which step caused it. Commit at every green step.

Try it yourself

On a branch, make two small changes with the tool. After each, stage only the right files, ask for a commit message using the prompt above, edit it and commit. Then ask for a pull request description based on the branch. Count the claims in it and verify each one against the diff.

This course is free to read. Create a free account to enrol, save your progress and pick up where you left off.

Sign up free I already have an account