Session 5: Branches

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

Course at University of Hamburg

Slides | Source

License: CC BY 4.0 DOI

May 06 2024 (12:15 pm)

Schedule

No Date Title Contents Reading Survey/Quiz
1 2024-04-08 Introduction to version control Organisational matters
Overview of seminar sessions
Introduction to version control
Introduction to Git and its advantages
Intro to version control Course introduction Survey
2 2024-04-15 Command line File Systems
Benefits of the Command Line
Basic Command Line commands
Command Line Command Line Quiz
3 2024-04-22 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-04-29 Basic Git workflow Practicing basic Git commands
Ignoring files with .gitignore
Good commit messages
First steps with Git Git Basics Quiz
5 2024-05-06 Git Branching and Merging Understanding branches in Git
Creating and switching between branches
Merging branches
Resolving merge conflicts
Branches Git Branches Quiz
6 2024-05-13 Quarto Workshop Introduction to Quarto
7 2024-05-20 Whit Monday Cancelled
8 2024-05-27 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-06-03 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-06-10 GitHub with the world Forking a remote repository
README files
Project Management
GitHub Intro, GitHub Issues GitHub Quiz
11 2024-06-17 Repetition and Practice Repetition and Practice
12 2024-06-24 Publishing Creating Tags with Git
Creating Releases with GitHub
Using Zenodo for scientific publishing
Licences
Citation Files
Tags and Releases
13 2024-07-01 Graphical User Interfaces (cancelled) Repetition and Practice
Introduction to using GUIs
Graphical User Interfaces
14 2024-07-08 Summary & Wrap-Up Course evaluation
Repetition and Practice
Introduction to using GUIs
Graphical User Interfaces

1 Last week: First steps with Git

Last week: First steps with Git

lennartwittkuhn.com/version-control-book/chapters/first-steps-git.html

Last week’s question: Saving command line history?

Use this:

history > history.txt

https://lennartwittkuhn.com/version-control-book/chapters/command-line.html#saving-command-line-history

Last week’s question: Commit .gitignore?

Yes, commit your project-specific .gitignore file.

https://lennartwittkuhn.com/version-control-book/chapters/first-steps-git.html#ignoring-files-and-folders-.gitignore

Last week’s learning objectives

Setup

💡 You know how to set up Git for the first time
💡 You have set up Git on your computer
💡 You understand the difference between the three Git configuration levels
💡 You know how to configure your username and email address in Git
💡 You have set up your preferred text editor when working with Git
💡 You can escape the command-line text editor Vim

First steps with Git

💡 You can initialize a Git repository
💡 You can stage and commit changes
💡 You know how to explore the commit history
💡 You can compare different commits
💡 You know how to use and create a .gitignore file
💡 You can discuss which files can (not) be tracked well with Git and why
💡 You know how to track empty folders in Git repositories

2 Survey results

Recap: Best practices for commit messages

  • Try to keep commit messages short (less than 72 characters)
  • Use present tense and start with an imperative verb to indicate the purpose of the commit, for example “add”, “fix”, “improve” (as if you are giving orders to the codebase to change its behavior)

If applied, this commit will … [your commit message]

  • Try to describe why a change is being made
  • Link specific issues that are addressed by your commit
  • Use the description for more explanation and context

3 Today’s topic: Branches

Today’s topic: Branches

Figure 1: Image from Chapter “Git Branches” of the “The Turing Way handbook to reproducible, ethical and collaborative data science”, used under a Creative Commons Attribution 4.0 License.

Today’s chapter

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

This weeks learning objectives

💡 You understand the purpose and benefits of using branches in Git
💡 You can create and switch between branches
💡 You can merge branches and resolve merge conflicts
💡 You can name at least three best practices when working with branches

Your turn

  1. Content Review: Read the chapter “Branches” in the Version Control Book.
  2. Implementation: Try out the commands in the chapter! Play around! Have fun!
  3. Note: We will do the implementation exercises in class together, step-by-step.
  4. Exercises: Complete the exercises in the survey.

Ask questions!

Let’s git started!

and branch out

Implementation Exercises

1. Create and merge a branch

  1. Create a new branch called feature.
  2. Switch to your new branch.
  3. Add a new recipe to your recipes text file.
  4. Switch back to the default branch (main or master).
  5. Merge the feature branch with your default branch and delete the feature branch afterwards.

2. Create and resolve a merge conflict

Deliberately create a merge conflict by editing the same section of a file on two separate branches and attempting to merge them. An example can be found in the Version Control Book chapter. Resolve the merge conflict and delete the feature branch afterwards.

3. Complete the branches quiz

4 GUIs

GUIs

lennartwittkuhn.com/version-control-book/chapters/gui.html