Skip to content

Version control with Git — work safely and together

Commits, branches and why you never lose work

Version control is a system that remembers all changes to a project over time. Git is the most common. This means you can see what was changed when and by whom, go back to an earlier version, and work multiple people on the same project without stepping on each other's toes.

§Repository, commit and history

A repository (repo) is the project folder Git keeps track of. When you have made a meaningful change you collect it in a commit — a snapshot with a brief message about what you did. Commits together form the project's history so you can always follow development and go back.

§Branches and interweaving

A branch is an independent line of development. You typically create a new branch for a new feature or bug fix, work peacefully there, and merge it into the main line once it is complete. This means the main line can be kept stable while new work happens alongside.

  • 01Commit: a snapshot with a descriptive message
  • 02Branch: an independent line to work on
  • 03Merge: to merge one branch into another
  • 04Remote: a shared version of the repo, e.g. hosted online
  • 05Pull request: a request to have your work reviewed and merged

§Cooperation with a remote repo

When several people work together, a shared version of the repository sits on a server (a remote). You pull down others' changes and push your own up. A pull request lets the team review each other's code before it merges—it catches errors and spreads knowledge in the team.

§Conflicts are normal

If two people change the same piece of code, a merge conflict occurs. It is not an error, but something Git asks you to decide: which version should apply. Learn to read the conflict markers and choose consciously — then conflicts are a trivial part of everyday life rather than something scary.