ETC5513: Collaborative and Reproducible Practices
Tutorial 7
🎯 Objectives
- Practice version control workflow.
- Ammend commits.
- Visit past commits and create branches from those.
- Merging branches and deal with conflicts.
- Practice pull requests.
- Use git reset and git revert.
Forks, pull request, commits and inspecting differences between commits (work in pairs)
- Create a new public GitHub repository called Tutorial7-XX and replace XX with your initials. Include a README.md file.
- Create a new branch called
newbranchXX
and move the HEAD of your repo to the tip ofnewbranchXX
.
- In your new branch add a new file called
exerciseXX.qmd
and replace XX with your initials.
- Stage, commit and push the changes into the remote repo
- Create a new folder in
newbranchXX
calledfigs
and addfront.jpg
(you can find the figure here)
- Stage, commit and push the changes into the remote repo.
- Using
git log
andgit log --oneline
inspect the commits that you have made.
- Install the
tinytex
R package in your Rstudio session and add the following to theexerciseXX.qmd
title: "Reproducible and Collaborative Practices"
subtitle: "Tutorial 7"
author: "Your Name"
institute: "Department of Econometrics and Business Statistics"
output:
pdf:
toc: true
toc_depth: 2
number_sections: true
highlight: tango
header-includes:
- \usepackage{titling}
- \pretitle{\begin{center} \includegraphics[width=5in,height=13in]{figs/front.jpg}\LARGE\\}
- \posttitle{\end{center}}
- \usepackage{fontawesome}
- \usepackage[most]{tcolorbox}
- \usepackage{xcolor}
- \usepackage{sectsty}
- \sectionfont{\color{olive}}
- \usepackage{verbatim}
Use
git status
andgit log --oneline
to inspect your repo.Stage
exerciseXX.qmd
.
- Unstage
exerciseXX.qmd
.
- Stage and commit changes into the remote repo. Do not push yet.
- Amend this last commit.
- after that in your terminal you can use :q to get out of the text editor
- You can also right click on your last commit in the VSCode tree and select edit commit message.
- Add one new section into the
exerciseXX.qmd
.
- Stage, commit and push the changes into the remote repo.
- Inspect the differences between your last two commits.
git diff oldestcommit_SHA .. HEAD --color-words
- Go back to a previous commit of your choice and create a new branch from there.
git checkout SHA/SHA1
.
- Checkout into the new branch and add a new section into
exerciseXX.qmd
. Then merge this new branch into your partner’s branch.
- Create a pull request from your branch to main, accept the change and deal with any possible merge conflicts.
Closer look to commits, revert to previous commits and reset your repository.
Use RStudio to inspect your previous exercise repo.
Inspect the tree and commits.
Create a new section in exerciseXX.qmd.
Stage, commit and push the changes.
Add a new latex list inside the last section that you have created.
Stage, commit and push the changes.
Go back and find the SHA number of the second last commit and use
git reset --mixed SHA
orgit reset --mixed HEAD~1
. Typegit status
and observe what has changed. How many commits do you have now in your repo now?
- In the terminal use
git revert
to go back to one of your previous commits.