In this course we will use Git, a version control system that allows you to track changes and share your code, and you will submit most of your assignments through GitHub, a website that implements Git and allows you to share code with others. Most software developers use these tools, and a large number of R packages are hosted and can be downloaded from GitHub.
- Choose available Username (keep it professional)
- Choose the free plan
Now let us know your GitHub account name is. Go here, click on “New Issue”, make the title “Add me to the organization”, and click on “Sumbit new issue”.
For each assignment we will create a new repository in https://github.com/UW-POLS503. First you need to make a copy of that repository to your GitHub account. We call that to create a “fork”.
https://Github.com/<your_account>/Assignment_00
.You created a copy of the assignment repository in your GitHub online account. Now you need make a copy of it in your local machine. We call that to “clone” a repository.
File > New Project > Version Control > Git
https://Github.com/<your_account>/Assignment_00
. If you don’t give it a “Project directory name”, it will create a directory named “Assignment_00” that will have the original files in the repository plus an .Rproj
and .gitingore
file.Access a terminal from within RStudio: Tools > Shell…
In the terminal enter the following commands:
git add *
git commit -m 'my first commit'
git push
Git
is going to ask for you GitHub account. Type it and Press enter
.enter
after typing the password and you should be good to go!Now that you pushed your assignment to your online fork of the repository, the last step is to send a pull request
to add your changes to the main repository.
https://Github.com/<your_account>/Assignment_00
Another graphical interface for Git and GitHub, not directly tied to RStudio, is GitHub Desktop. You may want to install that as an alternative to working with GitHub through RStudio.
If you are using git with R markdown, you will want to add a few patterns to your https://help.github.com/articles/ignoring-files/ file to ignore some temporary files.
# Ignore temporary files created by R markdown
*.utf8.md
*.knit.md
# Ignore knitr cache
*_cache/
If you are using git with R markdown, you will want to add a few patterns to your https://help.github.com/articles/ignoring-files/ file so that git ignores the many intermediate files that LaTeX creates when compiling a document.
For those more comfortable with git and LaTeX see this Stack Overflow post on a git+LaTeX workflow. Copy the patterns from GitHubs collection of useful gitignore patterns for TeX.
Note that although for this course we use git through either the GitHub website or client, or RStudio’s interface, git is often used in a shell. If you are unfamiliar with a shell, here are some places to get started:
Parts of this module are abstracts from Hadley Wickham’s module on Git and GitHub