Skip to content
Auf Deutsch ansehen

Lesson10 min

Git and GitHub: the safety net

A coding agent changes twenty files in a minute. Without version control there is no way back. Five terms and eight commands that are enough to entrust a project to an agent – even without a developer background.

Boaz Lichtenstein

Part of the path Building with coding agentsstation 1 of 5level 3 Expert

An agent that writes code is fast – at breaking things too. It overwrites files, deletes lines it considers superfluous and changes three places at once. That is not a problem as long as you can see at any time what changed and take it back. That is exactly what Git is for.

Five terms

Repository. Your project folder together with its entire history. Repo for short.

Commit. A recorded intermediate state with a short description. Every commit is a point you can return to.

Branch. A fork. On a branch something can be tried out without the main line – usually main – being touched.

Remote. The copy of the repo on a server. GitHub is the most widespread service for it.

Pull request. The proposal to take a branch into the main line – with all changes compared, room for comments and automatic checks. PR for short.

Eight commands that are enough

git init                  turn a folder into a repository
git status                what has changed since the last commit?
git add .                 stage all changes for the commit
git commit -m "text"      record the intermediate state
git switch -c attempt     create a new branch “attempt” and switch to it
git diff                  view changes line by line
git log --oneline         the history in short form
git restore .             discard all uncommitted changes

You do not need to know them by heart – an agent runs them on request. But you should know what they do before you agree. git restore ., for instance, deletes everything not yet committed, without asking.

The routine before every agent run

  1. git status – is the state clean? If not: commit first.
  2. git switch -c <name> – a separate branch for this task.
  3. Let the agent work.
  4. git diff – look at every change before it is committed.
  5. Commit or discard.

These five steps turn “the agent did something” into “the agent proposes exactly these changes”.

What never belongs in a repository

Passwords, API keys, credential files. Whatever has been committed once is in the history – even after deletion. Such files, usually .env, belong in the .gitignore file, which tells Git what to overlook. Check that before you upload a repo to GitHub, and tell the agent in the rules file.

GitHub as a place of work

GitHub is more than a backup:

  • Issues are the project’s task list. A well-written issue is at the same time a good brief for an agent.
  • Pull requests are the place of review – by people, by automatic tests and increasingly by agents.
  • Protected branches prevent anyone from writing directly to the main line. Agents included.

Private repositories are free. One is enough to start with.

Not just for code

Anything that consists of text files can be secured this way: a notes vault, a collection of prompts, the copy of a website. As soon as an agent may write in it, the history pays off – the vault from the path Knowledge & context makes a good first repository.

The next station shows how the agents work for which you are stretching this net.

Self-test

You want to have an agent make a larger change. What do you do immediately beforehand?

On this learning path

Building with coding agentsStation 1 of 5

Next station

How coding agents work

You know how a coding agent reads, plans, edits and verifies – and which permissions you give it along the way.

10 minLesson