Instructor note
15 min teaching
Motivation
Someone has given you access to a repository online and you want to contribute?
We will learn how to make a copy and send changes back.
Then, we make a “pull request” that allows a review.
Once we know how code review works, we will be able to propose changes to
repositories of others and review changes submied by external contributors.
Commits, branches, repositories, forks, clones
repository: The project, contains all data and history (commits, branches, tags).
commit: Snapshot of the project, gets a unique idenfier (e.g.
c7f0e8bfc718be04525847fc7ac237f470add76e ).
branch: Independent development line. The main development line is oen called main .
tag: A pointer to one commit, to be able to refer to it later. Like a commemorave plaque
that you aach to a parcular commit (e.g. phd-printed or paper-submitted ).
cloning: Copying the whole repository to your laptop - the first me. It is not necessary to
download each file one by one.
forking: Taking a copy of a repository (which is typically not yours) - your copy (fork) stays
on GitHub/GitLab and you can make changes to your copy.
Cloning a repository
In order to make a complete copy a whole repository, the git clone command can be used.
When cloning, all the files, of all or selected branches, of a repository are copied in one
operaon. Cloning of a repository is of relevance in a few different situaons:
Working on your own, cloning is the operaon that you can use to create mulple
instances of a repository on, for instance, a personal computer, a server, and a
supercomputer.
The parent repository could be a repository that you or your colleague own. A common
use case for cloning is when working together within a smaller team where everyone has
read and write access to the same git repository.
Alternavely, cloning can be made from a public repository of a code that you would like
to use. Perhaps you have no intenon to work on the code, but would like to stay in tune
with the latest developments, also in-between releases of new versions of the code.