Introduction

Background

Git is open source software for keeping a history of your files as you change them. github.com is a commercial service built on top of it that stores your repositories online and adds a web interface. Git itself is deep enough for professional programmers, but most people need only a handful of commands.

GitHub offers buttons for everything below, through its website and its desktop application. This guide uses the command line instead: it is fewer steps once the commands are familiar, and it works the same on any machine.

Key Idea

Each project lives in its own repository, holding all of that project’s files. A repository exists in two places: one copy on GitHub, and one on your own disk, which you make by cloning it. You edit the local copy with your usual tools, then push your changes up, and git keeps the two in step.

Every version is kept. Nothing you have committed is lost, and you can retrieve any earlier state of any file.

If two people work in the same repository, git merges their changes by itself as long as they did not edit the same lines. Where they did, it stops and asks you to choose — see Editing repositories.