Automated Version Control


Figure 1

One same files called Press release.doc with modifications in different files using the words FINAL, VERSION, REVISED, APPROVED. Source: Proper Discord.
Tracking changes for the Press release.doc file. Never use the word “final” in a filename.

Figure 2

Tracking changes for the git-test file.
Tracking changes for the git-test file.

Figure 3

The most recent version of the git-test file is called “third version”.
The most recent version of the git-test file is called “third version”.

Figure 4

We can view the “first version” of the file git-test. We can also restore it with the Restore this version button.
We can view the “first version” of the file git-test. We can also restore it with the Restore this version button.

Figure 5

The Turing Way project illustration by Scriberia. Used under a CC-BY 4.0 licence. DOI: https://zenodo.org/doi/10.5281/zenodo.3332807.
The Turing Way project illustration by Scriberia. Used under a CC-BY 4.0 licence. DOI: https://zenodo.org/doi/10.5281/zenodo.3332807.

Figure 6

Changes Are Saved Sequentially

Figure 7

Examples of non-plain and plain text files.
Examples of non-plain and plain text files.

Figure 8

We can increase the reproducibility of our Open science projects with version control sytems like Git. Text and final results can be connected and executable by Data and code. From: “Ciencia reproducible: qué, por qué, cómo” https://www.revistaecosistemas.net/index.php/ecosistemas/article/view/1178
We can increase the reproducibility of our Open science projects with version control sytems like Git. Text and final results can be connected and executable by Data and code. From: “Ciencia reproducible: qué, por qué, cómo” https://www.revistaecosistemas.net/index.php/ecosistemas/article/view/1178

Figure 9

Concept map for automatic version control.
Concept map for automatic version control.

Setting Up Git


Figure 1

Changes Are Saved Sequentially
Each record of changes is called a commit. From: https://speakerdeck.com/alicebartlett/git-for-humans

Figure 2

Visual appearance of the Console.
Visual appearance of the Console.

Figure 3

Visual display with the recommended scopes selected. Optional scopes are “gist” and “delete_repo” to create a gist and delete repositories.
Visual display with the recommended scopes selected. Optional scopes are “gist” and “delete_repo” to create a gist and delete repositories.

Figure 4

Version history within a single branch.
Version history within a single branch.

Creating a Repository


Figure 1

Word cloud for Git from https://thoughtbot.com/blog/recommending-blog-posts

Figure 2

Workflow will show actions, git verb commands, and spaces.
Workflow will show actions, git verb commands, and spaces.

Figure 3

Initialize a Local Repository in your Workspace with the git init command verb
Initialize a Local Repository in your Workspace with the git init command verb

Figure 4

wolfman and dracula using computers for data analysis
Image by Bing, 2023, CC BY 4.0, created with Bing Image Creator powered by DALL·E 3

Figure 5

The Git tab in the Environments pane shows the status of your repository.
The Git tab in the Environments pane shows the status of your repository.

Figure 6

Set up Git once per computer. Initialize Git once per project.
Set up Git once per computer. Initialize Git once per project.

Figure 7

Show hidden files in an Local repository.
Show hidden files in an Local repository.

Figure 8

The .git folder is a hidden folder in a Local repository.
The .git folder is a hidden folder in a Local repository.

Figure 9

Visual appearance of the Terminal.
Visual appearance of the Terminal.

Figure 10

Initialize a Local Repository in your Workspace with the git init command verb
Initialize a Local Repository in your Workspace with the git init command verb

Figure 11

Use the git init command to initialize a Local Repository in your Workspace. Use git status to check the status of the repository.
Use the git init command to initialize a Local Repository in your Workspace. Use git status to check the status of the repository.

Tracking Changes


Figure 1

The Git Staging Area

Figure 2

Use git status to display the state of the working directory and the staging area. git add your changes before you git commit them to the Local repository. Use the git log to get the history of changes in it. Use git diff to compare these changes.
Use git status to display the state of the working directory and the staging area. git add your changes before you git commit them to the Local repository. Use the git log to get the history of changes in it. Use git diff to compare these changes.

Figure 3

The Git Commit Workflow

Ignoring Things


Remotes in GitHub


Figure 1

The Local Repository with Git Staging Area

Figure 2

Freshly-Made GitHub Repository

Figure 3

Creating a Repository on GitHub (Step 1)

Figure 4

Creating a Repository on GitHub (Step 2)

Figure 5

Creating a Repository on GitHub (Step 3)

Figure 6

The Local Repository with Git Staging Area

Figure 7

Freshly-Made GitHub Repository

Figure 8

Where to Find Repository URL on GitHub

Figure 9

GitHub Repository After First Push

Figure 10


Figure 11

Use git pull to download content from a remote repository to the workspace and update the local repository to match that content. Use git push to upload local repository content to a remote repository.
Use git pull to download content from a remote repository to the workspace and update the local repository to match that content. Use git push to upload local repository content to a remote repository.

Collaborating


Figure 1


Figure 2


Figure 3


Figure 4

screenshot of repository page with Settings then Collaborators selected, showing how to add Collaborators in a GitHub repository

Figure 5

After Creating Clone of Repository
In the Outbreak response scenario, now Wolfman has a local copy of the remote repository. They are already set up to collaborate for one project!

Figure 6

Click on “commit”. Select one commit.
Click on “commit”. Select one commit.

Figure 7

Replace age with sex commit. The removed content within lines is in red. The added content within lines is in green.
Replace age with sex commit. The removed content within lines is in red. The added content within lines is in green.

Figure 8

Use git fetch to download the remote content but not update your local repo’s working state, leaving your current work intact. Use git pull to download the remote content for the active local branch and immediately merge it. this can potentially cause conflicts.
Use git fetch to download the remote content but not update your local repo’s working state, leaving your current work intact. Use git pull to download the remote content for the active local branch and immediately merge it. this can potentially cause conflicts.

Figure 9


Figure 10


Figure 11


Figure 12


Figure 13

Use git clone to obtain a development copy of a remote repository. Like git init, cloning is generally a one-time operation. Use git pull to update the local repository to match the content in the remote repository.
Use git clone to obtain a development copy of a remote repository. Like git init, cloning is generally a one-time operation. Use git pull to update the local repository to match the content in the remote repository.

Conflicts


Figure 1

Different Versions Can be Saved

Figure 2

Multiple Versions Can be Merged

Figure 3

The Conflicting Changes

Figure 4

The Conflicting Changes

Figure 5

One feature branch and one main branch in Git.
One feature branch and one main branch in Git.

Figure 6

Two feature branches and one main branch in Git.
Two feature branches and one main branch in Git.

Figure 7


Figure 8

Two related modified lines must be part of the same commit.
Two related modified lines must be part of the same commit.

Figure 9

Two unrelated edits must be part of two isolated commits.
Two unrelated edits must be part of two isolated commits.

Wrap-up


Figure 1

Complete workflow with actions, git verb commands, and spaces.
Complete workflow with actions, git verb commands, and spaces.

Supplemental: Using RStudio for Git


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


Figure 4


Figure 5


Figure 6

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

Figure 7


Figure 8

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

Figure 9


Figure 10


Figure 11

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

Figure 12


Figure 13

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

Figure 14


Figure 15


Figure 16


Figure 17


Exploring History


Figure 1

Git Checkout

Figure 2

https://figshare.com/articles/How_Git_works_a_cartoon/1328266

Figure 3

Use git diff to compare changes since last commit or between commits. Use git checkout to undo changes by restoring the staging area (committed changes) or the local repository (last commit)
Use git diff to compare changes since last commit or between commits. Use git checkout to undo changes by restoring the staging area (committed changes) or the local repository (last commit)

Open Science


Licensing


Citation


Hosting