Git Gud with Git and R

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

If you're doing any kind of in-depth programming in the R language (say, creating a report in Rmarkdown, or developing a package) you might want to consider using a version-control system. And if you collaborate with another person (or a team) on the work, it makes things infinitely easier when it comes to coordinating changes. Amongst other benefits, a version-control system:

  • Git gudSaves you from the worry of making irrevocable changes. Instead of keeping multiple versions of files around (are filenames like Report.Rmd; Report2.Rmd; Report-final.Rmd; Report-final-final.Rmd familiar?) you just keep the latest version of the file, knowing that the older versions are accessible should you need them.
  • Keeps a remote backup of your files. If you accidentally delete a critical file, you can retrieve it. If your hard drive crashes, it's easy to restore the project.
  • Makes it easy to work with others. Multiple people can work on the same file at the same time, and it's (relatively) easy to keep changes in sync.
  • Relatedly, it makes it easy to get a collaborator. Even if your project is currently a solo effort, you may want to get help in the future, and a version-control system makes it easy to add project members. If it's an open-source project, you might even get contributions from people you don't know!

There are many version control systems out there, but a popular one is Git. You've possibly interacted with projects (especially R packages) managed under Git on Github, the online version of Git. And while you can get a fair bit done just with your browser and GitHub, the real power comes by installing Git on your desktop. Using git's command-line interface is a bear (here's a fake, but representative example of the documentation), but fortunately RStudio and RTVS provide interfaces that make things much easier. 

If you want to get started with Git and RStudio, Jenny Bryan has provided an excellent guide to setting up your system and using version control: Happy Git and Gitgub for the R User. The guide is quite long and detailed, but fear not: the pace is brisk, and provides everything you need to get going. During a two-hour workshop that Jenny presented at the RStudio conference, I was able to install Git for Windows, configure it with my GitHub credentials, connect it to RStudio, commit changes to an existing R package, and create and share my own repository. It's easier than you think! Just start with the link below, and work your way through the sections.

Jenny Bryan:  Happy Git and Gitgub for the R User

To leave a comment for the author, please follow the link and comment on their blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)