6. Fairytale on main¶
In this chapter, we are going to use the basic git workflow
by writing a fairytale with a team.
![]() |
A fairytale is a story in which anything can happen |
|---|---|
6.1 Exercise 1¶
On Codeberg, create a new repository.
![]() |
Easy peasy! |
|---|---|
6.2 Adding Collaborators¶
![]() |
A Collaborator is someone in your team |
|---|---|
To add Collaborators, in your repo, click on 'Settings' (at the top right), then click on the 'Collaborators' tab.
Add one or more Collaborators. Collaborators are people you work together with. They too can now modify the text.
6.3 Exercise 2¶
Add at least 1 Collaborator.
![]() |
Add me, I am the best! |
|---|---|
6.4 Basic workflow¶
![]() |
You already know this |
|---|---|
Clone the repository on your computer:
For example,
Navigate into the folder of that repository:
For example,
Modify the README.md, for example
![]() |
Fairytales usually start with 'Once upon a time' |
|---|---|
![]() |
Fairytales usually end with 'And they lived happily ever after' |
|---|---|
Do add, commit, push:
6.5 Exercise 3¶
Each team member must
- add a sentence to the fairytale
add,commitandpushit
If something goes wrong, go to the next paragraph.
![]() |
The story is unimportant here |
|---|---|
6.6 git pull¶
If at git push you get a long text similar to below,
you need to update your local repository, see below that :-)
richel@N141CU:~/codeberg/git_for_youngsters$ git push
To https://codeberg.org/richelbilderbeek/git_for_youngsters.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'https://codeberg.org/richelbilderbeek/git_for_youngsters.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
![]() |
If you read the text, you can read you should do a git pull |
|---|---|
The reason for this text is,
when you work together, it can be that the version on your computer is
outdated: a Collaborator can have pushed a new version as well.
To update, do:
![]() |
Tip: you can never do git pull too often |
|---|---|
![]() |
Tip: when in doubt, do git pull |
|---|---|
6.7 Exercise 4¶
At the same time, each team member must
- add a sentence to the fairytale
add,commitandpushit- get the message that suggests to do
git pull - do a
git pull
If you get an error message like below, move on to the next paragraph.
![]() |
If your team works smart, there will be few merge conflicts |
|---|---|
6.8 Merge conflict¶
When two people work on different files, or on different parts of the same
file, git can easily combine the changes. However, when git is not
sure what to do, it will give you a merge conflict.
For example, assume README.md is:
One person changes this to:
The second person, however, changes his/her version of README.md to:
When the first person pushes his/her work, there is no problem. A problem will arise when the second person tries to push (which fails), then pulls: a merge conflict. This looks similar to this:
richel@N141CU:~/codeberg/git_for_youngsters$ git pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 294 bytes | 294.00 KiB/s, done.
From https://codeberg.org/richelbilderbeek/git_for_youngsters
7879d89..5e32784 main -> origin/main
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
The second person, with the merge conflict, needs to solve this.
This can be done by editing README.md.
It will look similar to:
The <<s and ==s and >>s are nothing special: they are just text
and can be deleted like any other text.
The second person now needs to think and change the text to whatever is best, for example, to:
This is a change, hence a add, commit and push needs to be done.
6.9 Exercise 5¶
Work together on a fairytale, with 5 commits per person. Also, each person must have solved one merge conflict. If you get no merge conflicts, cause them.
![]() |
We work on a fairytale, as that 'always works' (unlike code) |
|---|---|



