|
4 | 4 | - Preparation should not take longer than 15 mins, should be a demo. |
5 | 5 | - Lecturers also prepare some. |
6 | 6 |
|
7 | | -## Tricks from Winter Team 2025/26 |
| 7 | +## Tricks from Winter Term 2025/26 |
8 | 8 |
|
9 | 9 | - Click on line number on GitHub and then `blame` to study history of file |
10 | 10 | - GitHub uses [gitignore templates](https://github.com/github/gitignore) if you create a `.gitignore` file from GitHub |
|
18 | 18 | - If you rebased/merged and messed up your history, use `git reflog` to go back to a previous state |
19 | 19 | - If you only need one file from another commit or branch, use `git checkout <branch_or_sha> -- <path>` |
20 | 20 | - Use [Git LFS](https://git-lfs.com/) for big files >10 MB or for non-diffable binaries (e.g., images, media, archives, shared libraries). |
| 21 | +- Use `git switch -c <branch-name>` to create a new branch and immediately check it out! |
| 22 | +- Don't get stuck thinking that branches are only used as feature branches or issue branches! You can always create a short-lived temporary branch for something small, like shelving an experimental change. |
| 23 | +- If a temporary branch is still too much overhead for you, you can instantly stash your local changes with `git stash`. Restore your stashed changes later with `git stash pop`. |
| 24 | +- Prefer `git add -p` over `git add [FILE]`. This allows you to specify what you want to add to a commit in a more fine-grained manner |
| 25 | +- A very nice alias for editing any earlier commit, without having to manually rebase: |
| 26 | +
|
| 27 | + ``` |
| 28 | + [alias] |
| 29 | + amend = "!f() { \ |
| 30 | + COMMIT=$(git rev-parse --short \"$1\") && \ |
| 31 | + git commit --fixup \"$COMMIT\" && \ |
| 32 | + GIT_SEQUENCE_EDITOR=true git rebase --autosquash --autostash --interactive "$COMMIT^"; \ |
| 33 | + }; f" |
| 34 | + ``` |
| 35 | +
|
| 36 | + Usage: e.g. `git add -p ...` and then `git amend HEAD~5`. This would add the staged changes to the fifth last commit. |
21 | 37 |
|
22 | 38 | ## Tricks from Winter Term 2024/25 |
23 | 39 |
|
|
0 commit comments