class: center, middle, inverse, title-slide # Reproducible research workflows for psychologists ##
Git & GitHub
###
Johannes Breuer & Frederik Aust ###
KU Leuven, 27.-28.04.2022
--- exclude: true --- layout: true name: git # Git --- name: vc Command line tool 1. Version control - Track changes to *text files* - Retain version history of snapshot (*commits*) - Track provenance (who, what, when) --- <img src="data:image/png;base64,#img/git-history.png" width="85%" id="zoom-margin" style="display: block; margin: auto;" /> --- template: vc 2. Branching - Alternative versions of files - Simultaneous asynchronous collaboration -- (Vuorre & Curley, 2018) --- <img src="data:image/png;base64,#img/git-branching.jpg" width="1600" style="display: block; margin: auto;" /> --- Why use Git? - Avoid mistakes, e.g. - Working on wrong version - Inadvertently deleting or editing files -- - Track and merge changes of multiple collaborators across multiple files -- - (Offsite backups) --- layout: false class: center, middle <img src="data:image/png;base64,#img/git-fire.png" width="" height="450px" style="display: block; margin: auto;" /> --- layout: false name: git-system # Git <img src="data:image/png;base64,#img/git-system.png" width="550px" height="" style="display: block; margin: auto;" /> --- <img src="data:image/png;base64,#img/github-logo.png" width="150px" style='float:right;' style="display: block; margin: auto;" /> # GitHub - Proprietary plattform - Free to use for academics - Host remote Git repositories -- - Provides slick web interface - Offers project management tools -- - Repositories can receive a DOI with [Zenodo](https://guides.github.com/activities/citable-code/) -- - Servers located in the USA (GDPR) --- # GitHub <!-- TODO: Add screenshots to overlays --> <img src="data:image/png;base64,#img/github-home.png" width="" height="450px" style="display: block; margin: auto;" /> --- layout:false <img src="data:image/png;base64,#img/github-new-repo.png" width="" height="600px" style="display: block; margin: auto;" /> --- <img src="data:image/png;base64,#img/gitlab-logo.png" width="150px" style='float:right;' style="display: block; margin: auto;" /> # GitLab - .highlight[Open source plattform] - .highlight[Can be hosted by your institution] -- - Host remote Git repositories - Provides slick web interface - Offers project management tools -- - .highlight[Servers can be located in your country] (GDPR) --- # GitLab <!-- TODO: Add screenshots to overlays --> <img src="data:image/png;base64,#img/gitlab-home.png" width="2272" style="display: block; margin: auto;" /> --- layout: false <img src="data:image/png;base64,#img/gitlab-new-repo.png" width="" height="600px" style="display: block; margin: auto;" /> --- layout: true template: git --- Clone your GitHub repository to your computer ~~~bash git clone git@github.com:crsh/my-first-repository.git` ~~~ .pull-left-45[ <img src="data:image/png;base64,#img/github-clone.png" width="450px" height="" style="display: block; margin: auto;" /> ] .pull-right-45[ <img src="data:image/png;base64,#img/rstudio-new-git.png" width="450px" height="" style="display: block; margin: auto;" /> ] --- .pull-left-50[ `.gitignore` - Files to ignore (do not track) - Each line specifies a [pattern](https://git-scm.com/docs/gitignore) - I typically add R Markdown cache files<br />(e.g., `.rdb`, `.rdx`) - `usethis:::git_ignore_lines` ] .pull-right-40[  ] --- **Adding files** ~~~bash git status # What has changed? git add . # Stage all changes git commit -m "My very first commit! :)" ~~~ .pull-left-45[ - New files are "untracked", not watched for changes - To start tracking "stage" and "commit" files ] .pull-right-55[ <img src="data:image/png;base64,#img/rstudio-git-commit.png" width="80%" height="" style="display: block; margin: auto;" /> ] ??? Amend a previous commit if you forgot to add a change --- template: git-system --- Now we can push changes to our remote repository ~~~bash git push ~~~ <img src="data:image/png;base64,#img/rstudio-git-pushed.png" width="700px" height="" style="display: block; margin: auto;" /> -- ~~~bash git pull ~~~ --- ~~~bash git log ~~~ <img src="data:image/png;base64,#img/rstudio-git-history.png" width="" height="450px" style="display: block; margin: auto;" /> --- **Standard Git workflow** ~~~bash git pull git status git add . git commit -m "Such exciting changes! :)" git log git push ~~~ --- GitHub provides a web interface for your repository - List of files - Overview of commit history <img src="data:image/png;base64,#img/github-commit.png" width="700px" height="" style="display: block; margin: auto;" /> --- layout: false class: middle, center # Exercise time .center[[Exercise](http://frederikaust.com/reproducible-research-practices-workshop/exercises/4_git_github_question.html)] .center[[Solutions](http://frederikaust.com/reproducible-research-practices-workshop/exercises/4_git_github_solution.html)]