ETC5513: Collaborative and Reproducible Practices

Tutorial 7

Author

Michael Lydeamore

Published

21 May 2024

🎯 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)

  1. Create a new public GitHub repository called Tutorial7-XX and replace XX with your initials. Include a README.md file.
  1. Create a new branch called newbranchXX and move the HEAD of your repo to the tip of newbranchXX.
  1. In your new branch add a new file called exerciseXX.qmd and replace XX with your initials.
  1. Stage, commit and push the changes into the remote repo
  1. Create a new folder in newbranchXX called figs and add front.jpg (you can find the figure here)
  1. Stage, commit and push the changes into the remote repo.
  1. Using git log and git log --oneline inspect the commits that you have made.
  1. Install the tinytex R package in your Rstudio session and add the following to the exerciseXX.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}
  1. Use git status and git log --oneline to inspect your repo.

  2. Stage exerciseXX.qmd.

  1. Unstage exerciseXX.qmd.
  1. Stage and commit changes into the remote repo. Do not push yet.
  1. 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.
  1. Add one new section into the exerciseXX.qmd.
  1. Stage, commit and push the changes into the remote repo.
  1. Inspect the differences between your last two commits. git diff oldestcommit_SHA .. HEAD --color-words
  1. Go back to a previous commit of your choice and create a new branch from there. git checkout SHA/SHA1.
  1. Checkout into the new branch and add a new section into exerciseXX.qmd. Then merge this new branch into your partner’s branch.
  1. 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.

  1. Use RStudio to inspect your previous exercise repo.

  2. Inspect the tree and commits.

  3. Create a new section in exerciseXX.qmd.

  4. Stage, commit and push the changes.

  5. Add a new latex list inside the last section that you have created.

  1. Stage, commit and push the changes.

  2. Go back and find the SHA number of the second last commit and use git reset --mixed SHA or git reset --mixed HEAD~1. Type git status and observe what has changed. How many commits do you have now in your repo now?

  1. In the terminal use git revert to go back to one of your previous commits.