-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_exercises.qmd
148 lines (104 loc) · 3.51 KB
/
git_exercises.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
format:
html:
output-file: "git_exercises"
output-ext: "html"
editor: source
engine: knitr
filters:
- webr-teachr
- quiz-teachr
webr:
# packages: ["kofdata"]
autoload-packages: false
---
# Git Exercises
In this exercise we will test how well you know how to set up Git in your workin directory.
## Exercise 1
How would you set up Git in your working directory ?
::: {.callout-caution}
## Your turn!
Identify the set of commands needed to set up Git on your machine!
:::
:::{.quiz-multichoice}
- [X] [`git init`]{hint="o"}
- [ ] [`git configuration`]{hint="x"}
- [ ] [`git start`]{hint="x"}
- [ ] [`git add`]{hint="x"}
:::
## Exercise 2
Let's say you changed, added or removed some files in the course of your work. How will you make these changes known to your colleagues?
::: {.callout-caution}
## Your turn!
Identify the commands needed to share your changes with others!
:::
:::{.quiz-multichoice}
- [X] [`git add`]{hint="o"}
- [ ] [`git final`]{hint="x"}
- [X] [`git commit`]{hint="o"}
<!-- TODO: determine whether you need to add the whole command, e.g. `Git commit -m "xyz"` -->
- [ ] [`git pull`]{hint="x"}
- [X] [`git push`]{hint="o"}
:::
# Git Collaboration
Now that you've set up your repository and shared your first commit with your teammates, you want to work on them together, and possibly simultaneously.
## Exercise 1
How do you go about ensuring that you don't get in eachothers way when working?
:::{.quiz-multichoice}
- [X] [Create a new branch]{hint="o"}
- [ ] [Create a new repository]{hint="x"}
- [ ] [Proceed as is]{hint="x"}
:::
## Exercise 2
Let's say you while you were away, you aren't sure whether your teammates were working on your project or not. What do you do before working again?
:::{.quiz-multichoice}
- [ ] [Ask them]{hint="x"}
- [X] [`git pull`]{hint="o"}
- [ ] [`git push`]{hint="x"}
:::
## Exercise 3
Commit messages are a good way to document your progress, for yourself and your teammates
::: {.callout-caution}
## Your turn!
Tick the following commit messages which you should avoid!
:::
:::{.quiz-multichoice}
- [X] [deleted files]{hint="o"}
- [ ] [fixed typo in readme.md]{hint="x"}
- [X] [small changes]{hint="o"}
- [X] [quick working session]{hint="o"}
:::
<!-- # Git Merge Conflicts
You and your colleagues were dilligent in your collaboration, but for some unknown reason, you still get the following output when trying to push your changes:
```bash
CONFLICT (content): Merge conflict in file-name.txt
Automatic merge failed; fix conflicts and then commit the result.
```
How would you go about fixing this?
:::{.quiz-multichoice}
- [X] [check in which file the conflict happened]{hint="o"}
- [X] []{hint="o"}
- [ ] [`git push`]{hint="x"}
::: -->
# Git Diverging Branches
You and a colleague have been working on a project, but someone forgot to pull before re-starting the work.
Now Git tells you that you have diverging branches. How do you deal with this issue?
```bash
On branch main
Your branch and 'origin/main' have diverged,
and have 1 and 2 different commits each, respectively.
```
## Exercise 1
::: {.callout-caution}
Cross all options which you could use to solve the issue of diverging branches.
:::
:::{.quiz-multichoice}
- [ ] [`git pull`]{hint="x"}
- [X] [`git rebase`]{hint="o"}
- [X] [`git merge`]{hint="o"}
:::
::: {.callout-caution}
If you have had trouble with these exercises, you might want to try the following resources:
- [H4Sci-Tasks 1-3](https://github.com/h4sci/h4sci-tasks/issues)
- [Git Katas](https://github.com/eficode-academy/git-katas)
:::