Session 9: Repetition & Practice

Track, organize and share your work: An introduction to Git for research

Course at University of Hamburg & Erasmus University Rotterdam

Slides | Source

License: CC BY 4.0 DOI

December 20 2024 (10:15 am)

1 Admin

Schedule

No Date Title Contents Reading Survey/Quiz
1 2024-10-18 Introduction to version control Organizational matters
Overview of seminar sessions
Introduction to version control
Introduction to Git and its advantages
Intro to version control Course introduction Survey
2 2024-10-25 Command line File Systems
Benefits of the Command Line
Basic Command Line commands
Command Line Command Line Quiz
3 2024-11-01 Setup + Git Fundamentals Installation and configuration of Git
Initializing a Git repository
Basic Git commands
Installation, Setup, First steps with Git Installation Survey, Git Basics Quiz
4 2024-11-08 Basic Git workflow Practicing basic Git commands
Ignoring files with .gitignore
Good commit messages
First steps with Git Git Basics Quiz
5 2024-11-15 Git Essentials (Repetition & Practice) Practicing basic Git commands
Ignoring files with .gitignore
Good commit messages
Git Essentials Git Basics Quiz
6 2024-11-22 Git Branching and Merging Understanding branches in Git
Creating and switching between branches
Merging branches
Resolving merge conflict
Branches Git Branches Quiz
7 2024-11-29 Quarto Workshop Introduction to Quarto
8 2024-12-06 Introduction to GitHub Introduction to remote repositories
Creating a GitHub account
Creating and managing repositories on GitHub
Pushing and pulling changes
GitHub Intro GitHub Quiz
9 2024-12-13 GitHub with collaborators Cloning a remote repository
Branching and merging in a collaborative environment
Pull Requests
GitHub Issues
Graphical User Interfaces (GUIs), e.g., GitKraken
GitHub Intro, GitHub Issues GitHub Quiz
10 2024-12-20 Repetition and Practice Repetition and Practice
11 2025-01-10 Git(Hub) with the world Forking a remote repository
README files
Project Management
GitHub Advanced, GitHub Issues GitHub Quiz
12 2025-01-17 Publishing Creating Tags with Git
Creating Releases with GitHub
Zenodo for publishing
Tags and Releases
13 2025-01-24 Graphical User Interfaces Course evaluation
Repetition and practice
Intro to Graphical User Interfaces
Graphical User Interfaces
14 2025-01-31 Summary & Outlook Course evaluation results
Surprise
Summary & Outlook

2 Last session: GitHub - Collaboration

Last session: GitHub - Collaboration

https://lennartwittkuhn.com/version-control-book/chapters/github-advanced.html

Last session’s learning objectives

💡 You know the purpose and components of a Pull Request.
💡 You know how to collaborate using the popular workflow strategy GitHub flow.
💡 You know the purpose and components of a README file.
💡 You can fork a repository.
💡 You can create a Pull Request from a forked repository.
💡 You can protect your main branch.

Reminders / FAQ

“Remember to cd in your city-guide project folder!”

  • Every time you open the command line, it starts at a default location (likely your home directory).
  • Check in which folder you are, using pwd (“print working directory”).
  • Use cd to move to your city-guide project folder before you start running the Git commands.

“My password is not shown!”

  • Sometimes, for example, when creating an SSH key, you are asked for a password.
  • Usually, a key symbol appears
  • The command line registers your password although you can’t see it!
  • Copy-pasting works too!
Generating public/private ed25519 key pair.
Enter file in which to save the key (/Users/user/.ssh/id_ed25519):
Created directory '/Users/user/.ssh'.
Enter passphrase (empty for no passphrase): # now just enter your password!

Questions from last session

“Remember to clone your collaborator’s repository to a different location (not into your city-guide project folder!)”

  • cd out of your city-guide project folder
  • Clone into a different folder git clone git@github.com:partner-name/repo-name.git city-guide-partner

“Remember to use the SSH URL (not HTTPS) when cloning or configuring the remote repository!”

  • When you authenticate via SSH, you need to use the SSH URL!
  • This is relevant when your are configuring the remote, cloning a repository …
Code (HTTPS)
git remote add origin https://github.com/user-name/repo-name.git
Code (SSH)
git remote add origin git@github.com:user-name/repo-name.git

“My files don’t all show up on GitHub?!”

  • GitHub is no cloud sharing that synchronizes all files in a folder automatically!
  • Remember: Only files that are tracked by Git (that you added (git add), committed (git commit) to the repository) and then pushed (git push) are also transferred to GitHub.
  • Files that are untracked (check with git status) or ignored by .gitignore will not be transferred to GitHub, even if they are present in your local Git repository.

More questions about the last session?

3 This session: Repetition & Practice

Repetition & Practice

Image from Techdobz

GitHub Flow

Image from Sebass van Boxel

This and last session’s learning objectives

💡 You know the purpose and components of a Pull Request.
💡 You know how to collaborate using the popular workflow strategy GitHub flow.
💡 You know the purpose and components of a README file.
💡 You can fork a repository.
💡 You can create a Pull Request from a forked repository.
💡 You can protect your main branch.

Reading

“GitHub - Advanced”

Cheatsheet

Command Description
git blame Shows the authorship and commit information of each line in a file

Tasks

In this session, you will work on the following tasks:

  1. Reading: Read the chapter(s) “GitHub - Advanced” in the Version Control Book.
  2. Implementation: Try out the commands in the chapter.
  3. Exercises: Work on the exercises for the city-guide project.
  4. Quiz: Test your knowledge with the quiz.

As always:

  1. Try out the commands of this session and play around with them.
  2. Check whether you have achieved the learning objectives.
  3. Ask questions!
  4. Let’s git started!

city-guide project

At the end of this session, you should have accomplished the following:

  1. You collaborated successfully on a shared project by adding and committing changes to a partner’s repository.
  2. You created and reviewed a pull request to integrate new content from a partner.

Please keep the city-guide folder! We will continue to use it in the following sessions.

Today’s team topic

  • Interview each other about your favorite things to do to relax and recharge.
  • Add the recommendation of your partner to your text file or Quarto file.
  • Help each other in completing the exercises.

Exercises

“Private” collaboration with pull requests (using GitHub Flow)

  1. Add your exercise partner as a collaborator to your project repository on GitHub.
  2. Clone your partner’s repository.
  3. Create a new branch in your collaborator’s repository.
  4. Add a new entry to your collaborator’s project file (e.g., .txt or .qmd (if you are unsure, where to add the entry, ask your collaborator!)
  5. Add and commit the changes.
  6. Push the changes on the new branch to the remote repository.
  7. Create a Pull Request (on GitLab: Merge Request).
  8. Review the Pull Request that your collaborator made in your repository.
  9. 🚀 Optional: Add additional changes on the branch pushed by your collaborator.
  10. Merge the pull request into your repository.

Add a README.md

  1. Find the option to create a new file on your remote repository in the browser.
  2. Name the file README.md, add a brief description, and provide a commit message.
  3. 🚀 Optional: Play around with Markdown syntax.
  4. Save the README.md file to the repository.
  5. Pull the changes to your local repository.

Bonus exercises

🚀 Optional: Clean up your repository

Files that your repository should include:

  • a city-guide.qmd (see exercise in Session 07 on “Quarto”) or city-guide.txt file (see exercises starting in Session 02), or a similarly named file that includes the entries for the city-guide project
  • a .gitignore file (see exercise in Session 04 on “Basic Git workflow”)
  • a README.md file (see exercise in Session 09 on “Repetition & Practice”)

While this is not mandatory, please try to remove any unnecessary files or clutter, like empty .txt files from your repository. You can delete files directly on GitHub by clicking on the three dots next to the directory or file and selecting “Delete file,” then commit the changes. This effectively runs git add and git commit on GitHub. Alternatively, delete them from your local repository, add, commit and push the changes to GitHub.

4 Live demonstration