GitHub and repo orientation
In this week’s workshop, we will introduce version control using Git. Here are some of the topics that we’ll cover:
- Git vs GitHub
- What a repo is and how to navigate one
- README, folders, docs, branches, issues
- Basic workflow: clone, status, add, commit, pull, push
- What branches and pull requests are for
- GitHub as a way to understand and maintain a project, not just write code
Introduction
Lab
Initialise a repo and commit changes
Create a new Git repository on your local machine called icebreaker. Add a file called questions.md which includes the following:
- What was your dream job when you were a child?
- Would you prefer to travel back in time or be able to fly?
- What’s the most delicious thing you’ve eaten recently?
Stage and commit the file.
Now add your answers to the questions and commit your changes. Use git diff and git log to explore the differences and commit history.
Answer
#| eval: false
#| code-fold: true
#| code-summary: Show solution
pwd # print path of current folder
cd Projects # change current folder e.g. Projects
mkdir icebreaker # create new folder called icebreaker
cd icebreaker # change current folder to icebreaker
git init # track file within folder
touch questions.md # create new markdown file
ls # check contents of folder
nano questions.md # open nano text editor and enter questions
git add questions.md # include file in next commit
git commit -m "Unanswered questions" # commit changes
nano questions.md # add answers to questions
git diff # check unstaged changes
git add questions.md # include file in next commit
git commit -m "Answered questions" # commit changes
git log # print commit history
Optional
Your answers are currently stored in a local repo called icebreaker. To add questions.md to the statschat-course remote repo you need to clone the repo and push the file to a new branch. This branch will be named after your GitHub username.
#| eval: false
cd Projects # change current folder e.g. Projects
git clone https://github.com/tech-acs/statschat-course.git # clone statschat-course repo
cd statschat-course # change current folder to statschat-course
git checkout -b username # create and check out a new branch named after your GitHub username
git push -u origin username # push your <username> branch to the remote repo
You can then copy your answered questions.md over to the local statschat-course repo and push it to your remote branch.
Further reading
- Git SCM. Official Git Documentation. https://git-scm.com/docs/gittutorial.
- Kerr, K. (2025, March 18). What is Git? Our beginner’s guide to version control. GitHub Blog. https://github.blog/developer-skills/programming-languages-and-frameworks/what-is-git-our-beginners-guide-to-version-control/
- Visual Studio Code. (2022, May 27). Using Git with Visual Studio Code [Video]. YouTube. https://www.youtube.com/watch?v=i_23KUAEtUM
- Bartlett, A. (2016, November 4). git for humans [Conference presentation]. UXBri. https://speakerdeck.com/alicebartlett/git-for-humans
- Perez-Riverol, Y., Gatto, L., Wang, R., Sachsenberg, T., Uszkoreit, J., Leprevost, F. da V., Fufezan, C., Ternent, T., Eglen, S. J., Katz, D. S., Pollard, T. J., Konovalov, A., Flight, R. M., Blin, K., & Vizcaíno, J. A. (2016). “Ten Simple Rules for Taking Advantage of Git and GitHub”. PLOS Computational Biology, 12(7), e1004947. https://doi.org/10.1371/journal.pcbi.1004947
- Oh Shit, Git!?! https://ohshitgit.com/