Getting started with git for version control
2024-07-12
final_version.docx 🎉
final_version_corrected_supervisor1.docx
final_version_corrected_supervisor2.docx
final_version_tookmehourstocombineallcomments.docx 🤯
final_version_corrected.docx
..
.git/
git add index.qmd
git commit -m "Adds a paragraph"
Stage and commit in one command:
git commit -am "Adds a paragraph"
git status
git log --oneline
git restore index.qmd
git restore --source fa4f3deac index.qmd
git reset [--soft|--hard|--mixed] fa4f3deac
Sync with a remote (e.g. on GitHub)
All commits are associated with a user
If you’re collaborating:
Make sure to sync with the remote regularly (git pull
+ git push
)
Work with branches and pull requests
Create an empty repository on GitHub
Link your local repository to the created repository:
git remote origin https://github.com/OWNER/REPOSITORY.git
git push -u origin main
.gitignore
enables you to not version control files, e.g.:
_site/
.Rproj.user
Tag a special commit
Typically this is done to create versions, e.g. v1.0.0
With git tag
or creating a release in GitHub
For Zenodo: a DOI is linked to a release
Work in the main
branch - contains the source files
Use quarto publish gh-pages
to:
Create a branch called gh-pages
and push the rendered html files
Tell GitHub to use the files in gh-pages
to host it as a website
Find your website at OWNER.github.io/REPOSITORY 🚀
GitHub actions: jobs running on the GitHub server that can be triggered by e.g. a push, merge, cron job etc.
Let GitHub actions render the content - ultimate reproducibility
.github/workflows/my_workflow.yml
For most purposes steps have predefined actions
Spend time to learn it! You’ll earn it back quickly 💸
Nice resources:
If you’re new (or smart) use a git client, e.g.:
Rstudio git interface