Git fundamentals: commits, history, and branches

This course is for people who have used a computer but never version control. You don't need to be a programmer; writers, designers, students, and anyone who edits files can use Git. By the end, you'll be able to start a Git repository, save your work, look back in time, get an old version of a file back, and try ideas safely on a separate branch — all in your own terminal.

By the end you'll be able to (course objectives):

  • Explain what a Git repository is and why it protects your work.
  • Initialize a new Git repository in a folder on your computer.
  • Save a snapshot of your files with a clear commit message.
  • Read the history of your commits and recover an earlier version of a file.
  • Create a branch, work on it, and merge it back.
  • Walk through a small everyday workflow that combines all of the above.

Prerequisites: None beyond using a computer. You should be able to open a terminal or command prompt and type basic commands like cd, mkdir, and ls/dir. If those feel unfamiliar, take this library's Terminal basics first, then come back.

Practice environment: Your own terminal. This course has no embedded sandbox.

Lessons

#TopicYou'll learn
01Why Git exists: save points for filesVersion control, repository, commit
02Start a repo and make a commitgit init, git add, git commit
03Read history and recover a filegit log, commit hash, git restore
04Work on a branch without fearBranch, git switch, merge
05Put it together: a tiny workflowCombine init, commit, branch, recover

Sources listed in sources.md.