Last time: Debugging

Why Version Control?

“The person who knows the most about your code is you-six-months-ago, and you-six-months-ago are not replying to your emailed questions.”

~ Anon.

The features of version control:

Version control tools were designed for “code”, but are useful for all sorts of files (e.g. text reports for 36-401).

Git Basics

Git allows you to take “snapshots” of the contents of a folder on your machine as you make changes to them. Fix a bug? Take a snapshot. Add functionality? Take a snapshot. These snapshots are dubbed commits. Snapshot details are stored in the subfolder .git.

Github

Obtain a Github Account

If you do not have a GitHub account, get one at github.com.

Install Git

If you do not have Git installed on your laptop, install it!

During setup, configure Git with your user name (use your full name, not your Andrew ID) and your user email (which should be the same one you used to sign up for your GitHub account).

GitHub First…

For this lab, we will follow the paradigm of “GitHub first”. What this means is that when we create a repository, we will create it on GitHub first, then link a local repository to it from inside RStudio.

In GitHub, do the following:

…then RStudio

In RStudio, do the following:

At this point, you should find that your Files pane is listing the files in your local repository, including one ending in .Rproj and the README.md file that was created on GitHub.

Commits

Commits are lists of file changes + new lines + modified lines + deleted lines

The current state of your project is just the accumulated set of file changes over time.

Updating Your Repository

To, e.g., add a new file to your local repository, do the following:

Done.

Commit Messages

Commit messages exist for your benefit:

Remember that the reader (usually you) will not have full context

What should I commit?

Advanced Git

Merges

In Git, two commits can be merged by applying the relevant changes one after the other.

If the changes are independent this is straightforward.

If the changes conflict it needs to be manually merged (typically due to incompatible changes).

Sources of Information