Chapter 13. Git and GitHub

If you’re serious about software development, you need to learn about Git. Git is a version control system, a tool that tracks changes to your code and shares those changes with others. Git is most useful when combined with GitHub, a website that allows you to share your code with the world, solicit improvements via pull requests, and track issues. Git/GitHub is the most popular version control system for developers of R packages (witness the thousands of R packages hosted on GitHub).

Git and Github are generally useful for all software development and data analysis, not just R packages. I’ve included it here because it is so useful when you’re making a package. There’s no way I could be as productive without Git and GitHub at my back, enabling me to rapidly spot mistakes and easily collaborate with others.

Why use Git/GitHub?

  • It makes sharing your package easy. Any R user can install your package with just two lines of code:

    install.packages("devtools")
    devtools::install_github("username/packagename")
  • GitHub is a great way to make a bare-bones website for your package. Readers can easily browse code and read documentation (via Markdown). They can report bugs, suggest new features with GitHub issues, and propose improvements to your code with pull requests.

  • Have you ever tried to collaboratively write code with someone by sending files back and forth via email or a Dropbox folder? It takes a lot of effort just to make sure that the two of you ...

Get R Packages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.