Automated Version Control


Figure 1

Comic: a PhD student sends "FINAL.doc" to their supervisor, but after several increasingly intense and frustrating rounds of comments and revisions they end up with a file named "FINAL_rev.22.comments49.corrections.10.#@$%WHYDIDCOMETOGRADSCHOOL????.doc"
“notFinal.doc” by Jorge Cham, https://www.phdcomics.com

Figure 2

A diagram demonstrating how a single document grows as the result of sequential changes

Figure 3

A diagram with one source document that has been modified in two different ways to produce two different versions of the document

Figure 4

A diagram that shows the merging of two different document versions into one document that contains all of the changes from both versions

Setting Up Git


Creating a Repository


Figure 1

The main elements of the story: Dracula, Wolfman, the Mummy, Mars, Pluto and The MoonWerewolf vs dracula by b-maze / Deviant Art. Mars by European Space Agency / CC-BY-SA 3.0 IGO. Pluto / Courtesy NASA/JPL-Caltech. Mummy © Gilad Fried / The Noun Project / CC BY 3.0. Moon © Luc Viatour / https://lucnix.be / CC BY-SA 3.0.


Tracking Changes


Figure 1

A diagram showing how "git add" registers changes in the staging area, while "git commit" moves changes from the staging area to the repository

Figure 2

A diagram showing two documents being separately staged using git add, before being combined into one commit using git commit

Exploring History


Figure 1

A diagram showing how git restore can be used to restore the previous version of two files

Figure 2

A diagram showing the entire git workflow: local changes are staged using git add, applied to the local repository using git commit, and can be restored from the repository using git checkout

Ignoring Things


Remotes in GitHub


Figure 1

The first step in creating a repository on GitHub: clicking the "create new" button

Figure 2

The second step in creating a repository on GitHub: filling out the new repository form to provide the repository name, and specify that neither a readme nor a license should be created

Figure 3

The summary page displayed by GitHub after a new repository has been created. It contains instructions for configuring the new GitHub repository as a git remote

Figure 4

A diagram showing how "git add" registers changes in the staging area, while "git commit" moves changes from the staging area to the repository

Figure 5

A diagram illustrating how the GitHub "planets" repository is also a git repository like our local repository, but that it is currently empty

Figure 6

Clicking the "Copy to Clipboard" button on GitHub to obtain the repository's URL

Figure 7

A screenshot showing that clicking on "SSH" will make GitHub provide the SSH URL for a repository instead of the HTTPS URL

Figure 8

A diagram showing how "git push origin" will push changes from the local repository to the remote, making the remote repository an exact copy of the local repository.

Collaborating


Figure 1

A screenshot of the GitHub Collaborators settings page, which is accessed by clicking "Settings" then "Collaborators"

Figure 2

A diagram showing that "git clone" can create a copy of a remote GitHub repository, allowing a second person to create their own local repository that they can make changes to.

Conflicts


Figure 1

A diagram showing a conflict that might occur when two sets of independent changes are merged

Open Science


Licensing


Citation


Hosting


Supplemental: Using Git from RStudio


Figure 1

RStudio screenshot showing the file menu dropdown with "New Project..." selected

Figure 2

RStudio screenshot showing New Project dialog window with "Create project from existing directory" selected

Figure 3

RStudio window showing the "Create Project From Existing Directory" dialog. In the dialog, the project working directory has been set to "~/Desktop/planets"

Figure 4

RStudio window after new project is created with large arrow pointing to vertical Git menu bar.

Figure 5

RStudio window demonstrating the use of the editor panel to modify the "pluto.txt" file

Figure 6

RStudio screenshot showing the Git menu dropdown with the "Commit..." option selected

Figure 7

RStudio screenshow showing the "Review Changes" dialog. The top left panel shows the list of files that can be included or excluded from the commit. The top right panel is for writing a commit message. The bottom panel shows information about the currently selected file in the top left panel.

Figure 8

RStudio screenshot showing the git menu dropdown with the "History" option selected

Figure 9

RStudio screenshot showing the "Review Changes" dialog after pressing the "History" button. The top panel lists the commits in the repository, similar to git log. The bottom panel shows the changes included in the commit that has been selected in the top panel.

Figure 10

RStudio screenshot showing .gitignore open in the editor pane with the files .Rproj.user, .Rhistory, .RData, and *.Rproj added to the end