What is git?
Git is a version control system. That means you can keep records of all the changes you make to your R code (or any other file). This is important for several reasons. Among other things, git allows you to:
- easily recover from changes that cause the functionality of your code to break
- have all versions of your code accessible from a single location instead of strewn across your computer
- keep track of which versions of your code were used for different analyses or at different times
- collaborate efficiently with colleagues by always sharing the most recent versions of code
Anyone writing R code for actual analyses should learn and use a version control system such as git.
‘Git Basics: What is Version Control’ (from a series of instructional git videos):
Preparing your computer
Since only a subset of the people in R Club are comfortable using the command line interface, we are going to focus on learning git via a graphical user interface called SourceTree. SourceTree is a git client available for both Mac and Windows. There are several other git clients; however, SourceTree incorporates a branching model that we will use called git-flow.
Getting GitHub/Bitbucket accounts
Hosting your git repositories online simplifies collaborating, backing up your code in other places, and showing off your mad coding skillz. GitHub and Bitbucket are two online resources for hosting git repositories. Both services will host public git repositories free of charge. If you register with Bitbucket using an email address from an academic institution, you will automatically be upgraded to an academic account. This allows you to have private repositories for free. I typically prefer GitHub, however, since it seems to have a more active community and I prefer my projects be open-source anyway. In most respects, GitHub and Bitbucket are more or less equivalent.