Compare commits

...

1 commit

Author SHA1 Message Date
Tiziano Zito f7e6a26c00 add full lecture notes 2024-08-22 12:07:31 +02:00

View file

@ -13,9 +13,33 @@
— Lars Wirzenius (Linux kernel developer) — Lars Wirzenius (Linux kernel developer)
## Lecture notes ## Warm-Up
- how to start a repo from scratch?
- `git init` local method
- on an online forge (GitHub, GitLab, …): `git clone`
- how to revert mistakes?
- before commit:
- `git restore <file>` [discard changes in the working directory] __changes files__
- `git restore --staged <file>` [unstage changes ➔ opposite of `git add <file>`, does not modify the working directory]
- after commit:
- `git revert <commit>` [creates a new commit, modifies the working directory]
- `git reset <commit>` [only reset the HEAD pointer, does not modify the working directory] __rewrites history__ ➔ can not be used if you have already pushed to some remote
- `git reset --hard <commit>` [reset HEAD and modify working directory] __rewrites history__ and __changes files__ ➔ can not be used if you have already pushed to some remote
- how to *move* the whole working directory to a specific point in history?
- `git checkout <commit>``DETACHED HEAD` problem, __changes__ __files__
- interaction with branches: `git branch <branch_name>` + `git switch <branch_name>`
- how to copy a file from a different branch:
- `git checkout <branch> <file>` ➔ the file is staged automatically
- `git restore --source=<branch> <file` ➔ the file is not staged
- `git gui`: building commits along the way interactively (for the *mess around* type of workflows)
- check out these [sketches](git-commands-visualizations.pdf) for a graphical visualization of git commands!
… will follow after the lecture … ## The Open Source model
- remotes: `git pull <from_where> <what>`, `git push <where> <what>`, `git fetch <from_where> <what>`, `git merge <another_branch>`
- GitHub: forks, branches and PRs: important ➔ explain fork vs. clone!!!
- strategies for keeping your fork up-to-date: your `main`, origin's and upstream's `main`, short-lived and long-lived topic branches
- a more thorough and detailed explanation can be found on the [SciPy Contributor's Guide](https://docs.scipy.org/doc/scipy/dev/gitwash/gitwash.html). This guide can be adapted to your own needs, see [gitwash](https://github.com/matthew-brett/gitwash).
- make it clear that GitHub and GitLab are just options (git≠GitHub)
## Scenarios ## Scenarios
1. [lone scientist](scenarios/scenario1.png) working alone in the cellar without Internet (local git) 1. [lone scientist](scenarios/scenario1.png) working alone in the cellar without Internet (local git)