|
1 | 1 | # Git Tutorial |
2 | 2 |
|
3 | | -Sign-Up to the workshop here (being logged in with your DTU Microsoft account): [Sign-Up Form]( |
4 | | -https://forms.office.com/e/62H1nV61R0) |
| 3 | +Sign-Up to the workshop here (being logged in with your DTU Microsoft account): [Sign-Up Form](https://forms.office.com/e/62H1nV61R0) |
5 | 4 |
|
6 | 5 | ## Announcement |
7 | 6 |
|
8 | 7 | This workshop will give you the opportunity to practice git as a version control system |
9 | | -and Github as a website to host your repositories. Using git you can track changes in |
| 8 | +and Github as a website to host your repositories. Using git you can track changes in |
10 | 9 | folders. It allows you track your progress and to spot random typos when working on |
11 | | -many projects and tasks in parallel. In the workshop you will get the time to practice |
| 10 | +many projects and tasks in parallel. In the workshop you will get the time to practice |
12 | 11 | the fundamental concepts and actions directly in your browser - either using VSCode in |
13 | | -GitHub Codespaces or in using the GitHub web interface. If you want, you can also try |
| 12 | +GitHub Codespaces or in using the GitHub web interface. If you want, you can also try |
14 | 13 | everything on your local computer. |
15 | 14 |
|
16 | | -I will give a brief introduction to git. Then you will specific workflows by |
| 15 | +I will give a brief introduction to git. Then you will specific workflows by |
17 | 16 | collaboratively work on extending a [recipe book](https://enryh.github.io/recipe-book/) |
18 | 17 | (please bring a recipe you like). |
19 | | -You will learn how to work on |
20 | | -[branches](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches), |
21 | | -review [Pull Requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) |
22 | | -and merge them into the main branch. If you have specific requests, feel free to reach out to me. |
| 18 | +You will learn how to work on |
| 19 | +[branches](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-branches), |
| 20 | +review [Pull Requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests) |
| 21 | +and merge them into the main branch. If you have specific requests, feel free to reach out to me. |
23 | 22 |
|
24 | 23 | If you have specific requests, feel free to reach out to [me ](mailto:[email protected]) and/or write it down in the sign-up form. |
25 | 24 |
|
26 | 25 | What you'll learn: |
| 26 | + |
27 | 27 | - Basic tasks and actions to perform with git (in VSCode or in the browser) |
28 | 28 | - How to branch and tag |
29 | 29 | - Follow trunk-based development |
30 | 30 | - See how to merge and comment a Pull Request based on a branch |
31 | 31 | - Solve merge conflicts |
32 | 32 | - Familiarize yourself with VSCode’s and GitHub’s interface and user experience |
33 | 33 | - Get to know new recipes |
34 | | - |
35 | | -Minimal prerequisite: A [GitHub account](https://github.com/signup). |
36 | | -If you want to follow along locally, please install |
37 | | -[GitHub Desktop](https://desktop.github.com/download/) and |
| 34 | + |
| 35 | +Minimal prerequisite: A [GitHub account](https://github.com/signup). |
| 36 | +If you want to follow along locally, please install |
| 37 | +[GitHub Desktop](https://desktop.github.com/download/) and |
38 | 38 | [VSCode](https://code.visualstudio.com/) on your machine. |
39 | 39 |
|
40 | 40 | ### Brief timeline of the workshop: |
41 | 41 |
|
42 | | -| Time | Activity | |
43 | | -|---------------|----------------------------------------------| |
44 | | -| 10:00 - 10:15 | Coffee and snacks 🥐 | |
45 | | -| 10:15 - 10:45 | Introduction and example workflow | |
46 | | -| 10:45 - 12:00 | Working collaboratively on the recipe book | |
47 | | -| 12:00 - 12:30 | lunch break (not included) | |
48 | | -| 12:30 - 13:30 | Your question and advanced content | |
| 42 | +| Time | Activity | |
| 43 | +| ------------- | ------------------------------------------ | |
| 44 | +| 10:00 - 10:15 | Coffee and snacks 🥐 | |
| 45 | +| 10:15 - 10:45 | Introduction and example workflow | |
| 46 | +| 10:45 - 12:00 | Working collaboratively on the recipe book | |
| 47 | +| 12:00 - 12:30 | lunch break (not included) | |
| 48 | +| 12:30 - 13:30 | Your question and advanced content | |
49 | 49 |
|
50 | | -## Explore locally |
| 50 | +## Slides |
51 | 51 |
|
52 | | -You will need to setup your git email and user-name |
53 | | -(replace with yours in case you want to commit something, otherwise use copy-paste) |
| 52 | +<iframe |
| 53 | +src="https://docs.google.com/presentation/d/1RsKMiKquE4wqncrAv9LEtjivGE_dGiHoJ8nKCxgVKeY/embed?slide=id.p#slide=id.p" |
| 54 | +frameborder="0" |
| 55 | +width="100%" height="480" |
| 56 | +allowfullscreen="true" |
| 57 | +mozallowfullscreen="true" |
| 58 | +webkitallowfullscreen="true"> |
| 59 | +</iframe> |
54 | 60 |
|
55 | | -```bash |
56 | | -git config --global user.email "[email protected]" |
57 | | -git config --global user.name "Your Name" |
58 | | -``` |
59 | | -> could be added to local config using `git config user...` |
| 61 | +## Local Setup |
60 | 62 |
|
| 63 | +See [local_setup](local_setup.md) for instructions to setup git on your local computer. |
61 | 64 |
|
62 | 65 | ## Links to learn more |
63 | 66 |
|
64 | 67 | - [git-intro by coderefinery](https://coderefinery.github.io/git-intro/#) |
65 | 68 | - [git-moji](https://gitmoji.dev/) |
66 | 69 | - [Git Internals - Plumbing and Porcelain](https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain) |
67 | | -- [Glossary of terms (technical for git)](https://www.git-scm.com/docs/gitglossary) |
68 | | -- [GitHub Glossary terms](https://docs.github.com/en/get-started/learning-about-github/github-glossary) |
69 | | - |
70 | | - |
71 | | -## Git under the hood (Extended version) |
72 | | - |
73 | | -> Extended content for those interested in how git works under the hood |
74 | | -
|
75 | | -You can find a recording of the |
76 | | -[talk](https://www.youtube.com/watch?v=cAU3BCUkHxM) |
77 | | -([slides](https://docs.google.com/presentation/d/1RsKMiKquE4wqncrAv9LEtjivGE_dGiHoJ8nKCxgVKeY/edit?usp=sharing)) |
78 | | -and [hands-on tutorial](https://www.youtube.com/watch?v=5iB7qc5zRjQ) |
79 | | -on YouTube which was done for the Data Club seminar |
80 | | -between DTU biosustain and DTU bioengineering (see sections in description of Video). |
81 | | - |
82 | | -Talk: |
83 | | -[](https://www.youtube.com/watch?v=cAU3BCUkHxM) |
85 | | - |
86 | | -Live Demo: |
87 | | -[](https://www.youtube.com/watch?v=5iB7qc5zRjQ) |
89 | | - |
90 | | -The above Live Demo is not pulling the merge commit after merging the branch on GitHub: |
91 | | -[github.com/biosustain/git_training_henry_recording](https://github.com/biosustain/git_training_henry_recording) |
92 | | - |
93 | | -I show the merge commit in the video below, cloining the recording repository in a newly |
94 | | -create VSCode sandbox environment above: |
95 | | - |
96 | | -[](https://www.youtube.com/watch?v=gcfzruIJ-rw) |
98 | | - |
99 | | - |
100 | | -### Instructions |
101 | | - |
102 | | -- create a folder with an empty repository (default `examples` |
103 | | - directly openend in VSCode on binder) |
104 | | -- open instruction: `code-server ../README.md` (local computer: `code ../README.md`) |
105 | | -- `git init` in console to initialize repo (or via command palette "Git: Initialize Repository") |
106 | | -- setup user.name and user.email (see above) |
107 | | -- create files, stage them and see what files are created in `.git/objects` |
108 | | -- commit files and check `.git/objects` |
109 | | -- create branches and checkout `.git/refs` (`git/branches` is a legacy folder,see |
110 | | - [here](https://stackoverflow.com/a/10398507/9684872)) |
111 | | -- look at `git/HEAD` (maybe `git/ORIG_HEAD` if it exists) |
112 | | - |
113 | | -> try to create your own fork, and try to lauch it on [mybinder](https://mybinder.org/) |
114 | | -
|
115 | | -### Inspect git objects |
116 | | - |
117 | | -```bash |
118 | | -git log --format=raw |
119 | | -git cat-file -p <hash> # pretty print |
120 | | -git cat-file -t <hash> # type |
121 | | - |
122 | | -# the binary object can also be inspected using different tools, |
123 | | -# which might make it easier to navigate to certain blobs: |
124 | | -cat .git/objects/<2c>/<38c> | zlib-flate -uncompress |
125 | | -``` |
126 | | - |
127 | | -You can find the latest objects and compare it to the log |
128 | | - |
129 | | -```bash |
130 | | -find .git/objects -type f -exec ls -lt {} + | head -n 10 |
131 | | -git log --format=raw -n 3 |
132 | | -``` |
133 | | - |
134 | | -If you wonder what the codes in a tree mean, check this stackexchange |
135 | | -[answer](https://unix.stackexchange.com/a/450488/349761) |
136 | | - |
137 | | - |
138 | | -### What's happening? |
139 | | - |
140 | | -Can you explain what happens in the following scenarios? |
141 | | - |
142 | | -- You committed ten commits and did not yet push. Git complains about too much data. |
143 | | - You realize that you committed your source data. You delete it and commit again, |
144 | | - but the problem still persists. |
145 | | -- You commit something and push. You realize your last commit was wrong. You undo it |
146 | | - and commit again. Git complains that you cannot push. |
147 | | - |
148 | | -### Git internals resources |
149 | | - |
150 | | -- [curious git](https://matthew-brett.github.io/curious-git/) - detailed intro to the |
151 | | - inner workings |
152 | | -- [git parable](http://practical-neuroimaging.github.io/git_parable.html) - why git came to exist |
153 | | -- Videos: |
154 | | - - [Python-Git-Client](https://www.youtube.com/watch?v=xvzo_nV9PjU) |
155 | | - - [Git-Interals](https://www.youtube.com/watch?v=MYP56QJpDr4) - shows how git works |
156 | | - - [Git PyData Global 2021 talk](https://www.youtube.com/watch?v=rBYC3dEOOyI) |
157 | | - - Scoot Chacon’s [“So you thin you know git” talk](https://www.youtube.com/watch?v=aolI_Rz0ZqY) (FOSDEM 2024), |
158 | | - notes on [blog](https://blog.gitbutler.com/git-tips-1-theres-a-git-config-for-that/) |
| 70 | +- [Glossary of terms for git](https://www.git-scm.com/docs/gitglossary) |
| 71 | +- [Glossary terms for GitHub](https://docs.github.com/en/get-started/learning-about-github/github-glossary) |
0 commit comments