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 ?

Your turn!

Identify the set of commands needed to set up Git on your machine!

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?

Your turn!

Identify the commands needed to share your changes with others!

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?

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?

Exercise 3

Commit messages are a good way to document your progress, for yourself and your teammates

Your turn!

Tick the following commit messages which you should avoid!

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?

On branch main
Your branch and 'origin/main' have diverged,
and have 1 and 2 different commits each, respectively.

Exercise 1

Caution

Cross all options which you could use to solve the issue of diverging branches.

Caution

If you have had trouble with these exercises, you might want to try the following resources: