Setting up Git on Windows, Part 1

These days, Git is the default way to perform version control when developing code. I could go on a prolonged rant about how economists (and most social scientists, in my opinion) should invest a week of their time to learn how to stop worrying and love the tool. However, such rants can be easily found on Google, and, instead, I decided to draft up a quick guide on how to get Git up and running on a Windows machine. Git usually comes pre-installed on a Mac or Linux machine already, but the second part of the guide would be helpful for those platforms as well.

You will first need to obtain Git, I suggest getting the installer from git-scm.com. It is a pretty standard Windows-style installer, and I strongly encourage you to accept the default options: first, use Git only inside Git Bash, and second, checkout Windows-style, commit Unix-style. Other choices are less relevant.

Once the installation concludes, you can start Git Bash, and it will open up a terminal window with a standard Unix-style bash shell, which will be Git-aware. By default, the only editor it will support will be vi, which is powerful but has a steep learning curve. For new users I would instead suggest using nano, which is basically a Linux version of Notepad. Here is a post that details how to install nano on Windows and use it with Git. I would add to it that, to edit environment variables on Windows, you can follow this guide from Microsoft, which is a tad more detailed. Test your success by starting the Git Bash shell again and typing nano inside - if successful, press Ctrl+X to exit back to shell.

You are now all set to use Git locally, provided that you know how to do it. To harness Git’s full power, however, you will want to be able to interact with a remote repository. The two best web services to host a remote Git repository are GitHub and Bitbucket. GitHub offers free repositories with unlimited number of users, provided that you make all the code publicly accessible to everyone via their web interface; you would need to pay GitHub to make your code private. Bitbucket instead offers private repositories, but limits the number of users on them to five, and asks you to pay them if you need more users. The choice is yours to make, I use both for different applications.

In the next section I will discuss how you can push code to your GitHub/Bitbucket repositories and pull it back from them. Stay tuned.