Day 1: Concepts and a basic workflow
November 25, 2024
💻 Scientific programmer @ theoretical ecology group
🎓 PhD in dryland ecology modelling dryland ecohydrology
👩🏫 Teaching R, Git, good scientific practice, …
Git is very powerful …
… but can also be confusing in the beginning.
🎯 Learn simple Git workflows in theory and practice that you can immediately apply to your research projects.
Introduction to Git concepts and a simple workflow for your individual projects
Collaborate using Git and GitHub
Q&A session and/or more advanced topics
Until then: work with Git on your own projects
Material is all online
Certificate of attendance from the graduate center
All questions and comments are welcome
Feedback is welcome (Evaluation at the end of the workshop)
If possible, please turn on your camera
Did anyone have problems with the workshop preparation?
Complete and long-term history of every file in your project
Open source and free to use version control software
Quasi standard for software development
A whole universe of other software and services around it
For projects with mainly text files (e.g. code, markdown files, …)
Basic idea: Take snapshots (commits) of your project over time
Git is a distributed version control system
After you installed it there are different ways to interact with the software.
Using Git from the terminal
➕ Most control
➕ A lot of help/answers online
➖ You need to use terminal 😱
A Git GUI is integrated in most (all?) IDEs, e.g. R Studio, VS Code
➕ Easy and intuitive
➕ Stay inside IDE
➖ Different for every program
Standalone Git GUI software, e.g. GitHub Desktop, Source Tree, …
➕ Easy and intuitive
➕ Use for all projects
➖ Switch programs to use Git
Tip
Have a look at the website where you find How-To guides for the other methods as well.
git init
,git add
,git commit
,git push
A cook book project to collect all my favorite recipes.
In real life this would be e.g. a data analysis project, your thesis in LaTex, a software project, …
Git detects any changes in the working directory
Staging a file means to list it for the next commit.
Staging a file means to list it for the next commit.
Commits are the snapshots of your project state
Commits are the snapshots of your project state
Changes are part of Git history and staging area is clear again
✔️
See here for more details but some general rules:
Start your own cook book
Complete Task 1 “Local repo”
Stay in the meeting for the task.
Ask if you are stuck.
Turn down/off volume if you are disturbed.
Use remote repos (on a server) to synchronize, share and collaborate
Use remote repos (on a server) to synchronize, share and collaborate
GitHub/Gitlab are a good way to publish and share your work.
You can increase the quality/complexity of your repo by
If you are interested, browse some nice GitHub repositories for inspiration (e.g. Git training repository, Computational notebooks, Repo to publish code from a manuscript)
Publish your cook book on GitHub
Complete Task 2 “GitHub”
git init
: Initialize a git repository
.git
folder to your working directorygit add
: Add files to the staging area
git commit
: Take a snapshot of your current project version
git push
: Push new commits to the remote repository
git revert
git revert
to revert specific commitsRevert a commit from your cook book
Questions?
git checkout
Take your work space back in time temporarily with git checkout
.gitignore
.gitignore
.gitignore
Create a file with the name .gitignore
in working directory
Add all files and directories you want to ignore to the .gitignore
file
*.html # ignore all .html files
*.pdf # ignore all .pdf files
debug.log # ignore the file debug.log
build/ # ignore all files in subdirectory build
See here for more ignore patterns that you can use.
Selina Baldauf // Basic Git workflow