← Git from Scratch Lesson 16 of 17 · 5 XP

The workflow: branches and Pull Requests

Theory

Machine translation, not yet reviewed by a native speaker.

This is how almost every team works, including yours with Kai and Alex:

  1. git switch main && git pull — start from the latest version;
  2. git switch -c feature/login — a branch for one task;
  3. small commits with clear messages;
  4. git push -u origin feature/login;
  5. open a Pull Request (PR) on GitHub — a request to "merge my branch";
  6. review: colleagues read the code and leave comments, and automated tests (CI) check the build;
  7. merge into main, delete the branch.

A good commit message:

Add in-browser checking of C tasks

clang in WebAssembly compiles the solution, and a mini-WASI runs it
on each test. Reference solutions are checked by gcc on the server.
  • the first line — up to ~50 characters, what the commit does (imperative mood: "Add", "Fix", not "Added");
  • an empty line;
  • then, if needed, why, and the details.

Many teams use the Conventional Commits convention: feat: …, fix: …, docs: …, refactor: …. From these prefixes a list of changes can be put together automatically.

What not to do:

  • commit secrets (passwords, keys, .env);
  • huge "did everything" commits — nobody can review them;
  • git push --force to shared branches;
  • work directly in main in a team.

Sign up for free to mark finished lessons and track your progress.