Introduction

What is git? Before explaining what it is and how it works, let me explain what problem it is intended to solve.

Say your are editing a file. For example the draft of your paper (in Latex) or your stata code. You probably have many files with different versions because everytime you make a change, you think it is the right change to make, but you're not 100 percent sure so you want to keep a copy of your file without the change. So your folder is full of finaldraft.ext, finaldraftv2.ext etc... or maybe finaldraftoctober2017.ext, finaldraftnovemebr2017, etc... Keeping these files is a decent idea but there are at least two big drawbacks with this method:

  1. the more you go the bigger is your folder with more and more files. it becomes quite messy

  2. there is no way to know what you've changed in each of these files. Say you want to go back to the file where you ran regressions on the full population instead of the women only, as you do in the latest version of your paper. Which file should you pick? Do you remember the date or the version number?

Git is the tool most commonly used to solve these issues. It is also very useful for team collaboration in files and code, but we will let this on the side for now.

Git allows you to save a comment every time you save a file indicating what you have changed. It allows you to have different versions of the same file that you can load one after the other, merge later in time and so on...

Git requires some practice and has a non-negligible entry cost. But it is worth it.

Last updated