Reproducible Research › Module 3: Version control

Git in one idea

Lesson 1 of 3 · 2 min

Previous

Git is a tool that keeps the full history of your project. The one idea: a series of save points, each with a note.

Each save point is called a commit. It records exactly what every file looked like at that moment, plus a short message you write. You can go back to any commit, compare any two, and see who changed what.

Why researchers need it

  • No more final_v3_REAL: one file, full history.
  • Undo safely. Broke something? Go back to yesterday's commit.
  • Know which code made which result. Note the commit ID next to every figure.
  • Collaborate without emailing files back and forth.

The everyday loop

  1. Edit your files.
  2. git add the files you changed (choose what goes into the save point).
  3. git commit -m "a short message" (make the save point).
  4. Repeat. Commit small and often.

Git was created by Linus Torvalds in 2005 to manage the Linux kernel. Today it is the standard tool for software, and increasingly for research.

You don't need the command line

Graphical tools like GitHub Desktop, or the Git panel built into VS Code and RStudio, do the same thing with buttons.

What not to commit

Large data files, passwords and API keys. List them in a .gitignore file so Git skips them.

RememberGit is save points with notes. Commit small, commit often, and never commit secrets.