library(tidyverse)
library(palmerpenguins)
data(package = "palmerpenguins")
ggplot(penguins, aes(x = bill_depth_mm, y = flipper_length_mm, color = species)) +
geom_point()
ETC5513: Collaborative and Reproducible Practices
Tutorial 5
🎯 Objectives
- Create a repository in GitHub
- Create branches
- Merge
- Work with
.gitignore
files
Exercise 1: Git practice
Log into your GitHub account
Fork the following repo: https://github.com/ETC5513-2024/Tutorial-Branches
Clone this onto your computer
Open
README.md
in RStudio and delete any text that is inside the file. Using markdown language, add a heading with the title “This is tutorial 5”.Stage, commit and push the changes to the remote repository into GitHub
In the same
README.md
, add the following after the title: “In this tutorial we are learning to usegit rebase
, to create a.gitignore
file and to collaborate with others.”Commit and push the changes to the remote repository in GitHub.
Go to GitHub and make sure you have two commits in your repo history.
Create a new branch called “Tutorial5-Exercise1”. Checkout that branch and make sure you push the changes into the remote repository using
git push -u origin Tutorial5-Exercise1
.
Remember if you create the branch inside RStudio it will automatically be pushed to the remote repo in GitHub
- Create a file called
Tutorial5.qmd
on theTutorial5-Exercise1
branch that contains the following:
- Title: Learning to merge
- Author: [insert your name]
- Date information
- The file will render to HTML
Stage, commit and push the changes to the remote repo in GitHub. Then, merge the changes in your new branch into the main branch.
Swap to the main branch and add the following into Tutorial5.qmd:
- Stage, commit and push the changes into
main
in your remote repo
- Add the following into Tutorial5.qmd:
ggplot(penguins, aes(x = species, y = bill_length_mm, fill=species)) +
geom_boxplot(outlier.colour = "blue", outlier.size = 2) +
geom_jitter(width=0.2, alpha = 0.5) +
labs(title="Penguin Bill Length") +
theme_light()
Create a new file called
ignoring.txt
and a new file called.gitignore
usingtouch
. Make sure the files are create in your repo usingls -a
. State these files, commit and push them.In RStudio, open the
.gitignore
file and edit it to add a rule to ignore files with extension*.txt
.Stage, commit and push the changes into
main
in your remote repo.Inspect your git tree using the diff window in RStudio
Optional: Rebase the commits in your branch
Tutorial5-Exercise1
into mmain
and have a look at the git tree. Then, mergeTutorial5-Exercise1
intomain
and have a look at the git tree.
Exercise 2: Collaboration with pull requests
Exchange your GitHub repo details with your partner for this exercise
Fork each other’s repositories in your GitHub and clone a local copy
You may have to rename the fork when you do this. Put either your initials or your partners in the repo name to distinguish it.
Create a new branch and work on this branch.
Add a new section and a figure into the report.
Stage, commit and push the changes into your remote repo in GitHub.
Once you have finished with all the changes, merge your new branch into main.
Create a pull request explaining the changes.
Revise the pull request and accept the proposed changes.
Solve any possible conflicts and merges changes into your original repo that you created in Exercise 1.
If you have more time, repeat this exercise with more complicated changes. See if you can deliberately create a merge conflict!