git

Prof. Dr. Mirco Schoenfeld

git

Looking familiar?

git workflow

(Healy 2019)

git graph

Trunk:

Unnamed branch of a file tree under revision control

(Commons 2009)

git graph

Structure:

The structure of the revisions is not a tree (although it is often referred to as the revision tree) but a directed acyclic graph.

(Commons 2009)

git graph

Tag:

A tag assigns a label to a revision (including many files) allowing to directly jump to that revision. Often used to label a specific version of a software.

(Commons 2009)

Check git out

Let’s check git out!

https://github.com/TwlyY29/dmkg_intro_to_git

Check git out

https://github.com/TwlyY29/dmkg_intro_to_git

Check git out

https://github.com/TwlyY29/dmkg_intro_to_git

Check git out

https://github.com/TwlyY29/dmkg_intro_to_git

Check git out

https://github.com/TwlyY29/dmkg_intro_to_git

git going

Let’s git going!

Useful resources:

https://git-scm.com/book/en/v2 (Chacon and Straub 2014)

It’s your turn

  1. Create a repository on your machine.
  2. Add a new R Markdown document script.Rmd to it.
  3. Commit the current state.

Useful resources: https://git-scm.com/book/en/v2 (Chacon and Straub 2014)

And please have a look at the next slide!

It’s your turn - a tip

Avoiding vim-hell for git commits:

Change the default text editor for commit messages in the git bash before you do anything else:

Windows users:

git config --global core.editor "notepad"

Mac users:

git config --global core.editor “open -e -W -n”

https://zxtech.wordpress.com/2020/03/29/setting-textedit-as-default-git-editor/

git trunks and branches

Branching:

Duplication of an object under version control. Objects can then be modified separately and in parallel so that they become different. These objects are called branches.

(Commons 2009)

git trunks and branches

Merge:

A fundamental operation that reconciles multiple changes made to a version- controlled collection of files. Necessary when files are modified on two independent branches. The result is a single collection of files that contains both sets of changes.

(Commons 2009)

It’s your turn

  1. Create a new branch
  2. Add the script-document to it
  3. Modify the script document.
  4. Commit changes to the branch.

Useful resources: https://git-scm.com/book/en/v2 (Chacon and Straub 2014)

Break

git diff viewer

Meld for Linux: sudo apt install meld

It’s your turn

  1. Merge your new branch into the master branch.
  2. Commit the changes.
  3. Add the steps you took tot he document.
  4. Commit the changes.

Useful resources: https://git-scm.com/book/en/v2 (Chacon and Straub 2014)

git for collaboration

Git is great for collaboration. For example:

https://gitlab.gnome.org/GNOME/meld/-/project_members

git for collaboration

Merge/Pull requests:

https://gitlab.gnome.org/GNOME/meld/-/merge_requests/119

It’s your turn

  1. How can you use git as a collaboration plattform?
  2. What online platforms host git?
  3. Are there differences between online platforms?
  4. Add your findings to your script and commit the changes.

Useful resources: docs.github.com > Collaborative Coding > Pull Requests > Overview

git and plain text files

What is the most central requirement to efficiently use git?

Use Plain Text Files.

git and plain text files

LZV.NRW (2023)

References

Chacon, Scott, and Ben Straub. 2014. Pro Git (Second Edition). Apress. https://git-scm.com/book/en/v2.
Commons, Wikimedia. 2009. “Revision Controlled Project Visualization.” 2009. https://commons.wikimedia.org/wiki/File%3aRevision_controlled_project_visualization.svg.
Healy, Kieran. 2019. The Plain Person’s Guide to Plain Text Social Science. The Internet. https://plain-text.co/.
LZV.NRW. 2023. “Interactive Panel of Common File Formats.” 2023. https://www.q-terra.de/lzv/.