Git records the history of your code: every change is dated, described, and reversible. GitHub hosts these repositories online so you can share them and collaborate. It's a habit worth building from your very first project.

Essential for learning to code and for showing your work.

The mental model

A commit is a snapshot of your project at a moment in time, with a message attached. You can go back to it, compare it, or undo it. The history tells the story of how the project evolved.

The basic flow

  • Edit files.
  • Stage what you want to include in the next commit.
  • Commit with a clear message.
  • Push to the remote repository.

Branches

Working without breaking things. A branch is a parallel line of work. You develop a feature on its own branch, then merge it in once it's ready. The main branch stays healthy at all times.

GitHub

Collaborating and publishing. A remote repository, pull requests for review before merging, issues for tracking tasks, Pages for publishing a static site. It's also your public portfolio.

Getting unstuck

Common situations:

  • A merge conflict: Git shows you the conflicting sections, you choose, you commit.
  • A commit made on the wrong branch: you move it.
  • Undoing a change: depending on the case, cleanly rolling back is usually better than rewriting shared history.

Frequently Asked Questions

Are Git and GitHub the same thing?

No. Git is the version control tool, running on your machine. GitHub is a service that hosts Git repositories online (GitLab and Bitbucket do too).

Do I need to do everything from the command line?

No — a graphical interface or your editor's built-in integration is enough to start. Understanding the concepts matters more than how you type the commands.

When should I make a commit?

As soon as a small, coherent set of changes is ready. Frequent, well-named commits beat one giant catch-all commit.