You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Be able to decide whether to divide work at the branch level or at the repository level.
5
-
```
6
-
7
-
```{instructor-note}
8
-
- 15 min teaching
9
-
```
10
-
11
-
12
-
## Motivation
13
-
14
-
- Someone has given you access to a repository online and you want to contribute?
15
-
- We will learn how to make a copy and send changes back.
16
-
- Then, we make a "pull request" that allows a review.
17
-
- Once we know how code review works, we will be able to propose changes
18
-
to repositories of others and review changes submitted by external
19
-
contributors.
5
+
:::
20
6
21
7
22
8
## Commits, branches, repositories, forks, clones
@@ -33,68 +19,41 @@
33
19
34
20
## Cloning a repository
35
21
36
-
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 operation. Cloning of a repository is of relevance in a few different situations:
37
-
* Working on your own, cloning is the operation that you can use to create multiple instances of a repository on, for instance, a personal computer, a server, and a supercomputer.
38
-
* 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.
39
-
* Alternatively, cloning can be made from a public repository of a code that you would like to use. Perhaps you have no intention 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.
40
-
41
-
```{figure} img/overview/clone.png
42
-
:alt: Cloning
22
+
In order to make a complete copy a whole repository, the `git clone` command
23
+
can be used. When cloning, all the files, of all or selected branches, of a
24
+
repository are copied in one operation. Cloning of a repository is of relevance
25
+
in a few different situations:
26
+
* Working on your own, cloning is the operation that you can use to create
27
+
multiple instances of a repository on, for instance, a personal computer, a
28
+
server, and a supercomputer.
29
+
* The parent repository could be a repository that you or your colleague own. A
30
+
common use case for cloning is when working together within a smaller team
31
+
where everyone has read and write access to the same git repository.
32
+
* Alternatively, cloning can be made from a public repository of a code that
33
+
you would like to use. Perhaps you have no intention to work on the code, but
34
+
would like to stay in tune with the latest developments, also in-between
35
+
releases of new versions of the code.
36
+
37
+
38
+
:::{figure} img/overview/forkandclone.png
39
+
:alt: Forking and cloning
43
40
:width: 100%
44
41
:class: with-border
45
42
46
-
Cloning
47
-
```
43
+
Forking and cloning
44
+
:::
48
45
49
46
50
47
## Forking a repository
51
48
52
-
When a fork is made on GitHub/GitLab a complete copy, of all or selected branches, of the repository is made. The copy will reside under a different account on GitHub/GitLab. Forking of a repository is of high relevance when working with a git repository to which you do not have write access.
53
-
* In the fork repository commits can be made to the base branch (`main` or `master`), and to other branches.
54
-
* The commits that are made within the branches of the fork repository can be contributed back to the parent repository by means of pull or merge requests.
55
-
56
-
```{figure} img/overview/fork.png
57
-
:alt: Forking
58
-
:width: 100%
59
-
:class: with-border
60
-
61
-
Forking
62
-
```
63
-
64
-
65
-
## Generating from templates and importing
66
-
67
-
There are two more ways to create "copies" of repositories into your user space:
68
-
- A repository can be marked as **template** and new repositories can be
69
-
**generated** from it, like using a cookie-cutter.
70
-
The newly created repository will start with a new history, only one commit, and not
71
-
inherit the history of the template.
72
-
73
-
```{figure} img/overview/generate.png
74
-
:alt: Generating from a template
75
-
:width: 100%
76
-
:class: with-border
77
-
78
-
Generating from a template.
79
-
```
80
-
81
-
- You can **import** a repository from another hosting service or web address.
82
-
This will preserve the history of the imported project.
83
-
84
-
```{figure} img/overview/import.png
85
-
:alt: Importing a repository
86
-
:width: 100%
87
-
:class: with-border
88
-
89
-
Importing a repository.
90
-
```
91
-
---
92
-
93
-
```{discussion}
94
-
- Visit one of the repositories/projects that you have used recently and try to find out
95
-
how many forks exist and where they are.
96
-
- In which situations could it be useful to start from a "template" repository by generating?
97
-
```
49
+
When a fork is made on GitHub/GitLab a complete copy, of all or selected
50
+
branches, of the repository is made. The copy will reside under a different
51
+
account on GitHub/GitLab. Forking of a repository is of high relevance when
52
+
working with a git repository to which you do not have write access.
53
+
- In the fork repository commits can be made to the base branch (`main` or
54
+
`master`), and to other branches.
55
+
- The commits that are made within the branches of the fork repository can be
56
+
contributed back to the parent repository by means of pull or merge requests.
98
57
99
58
100
59
## Synchronizing changes between repositories
@@ -105,12 +64,23 @@ Importing a repository.
105
64
- We will learn how to suggest changes within repositories on GitHub and across repositories (**pull request**).
106
65
- Repositories that are forked or cloned do not automatically synchronize themselves:
107
66
We will learn how to update forks (by pulling from the "central" repository).
108
-
- A main difference between cloning a repository and forking a repository is that the former is a general operation for generating copies of a repository to different computers, whereas forking is a particular operation implemented on GitHub/GitLab.
67
+
- A main difference between cloning a repository and forking a repository is that the former
68
+
is a general operation for generating copies of a repository to different computers,
69
+
whereas forking is a particular operation implemented on GitHub/GitLab.
109
70
110
-
```{figure} img/overview/forkandclone.png
111
-
:alt: Forking and cloning
71
+
72
+
## Generating from templates
73
+
74
+
A repository can be marked as **template** and new repositories can be
75
+
**generated** from it, like using a cookie-cutter.
76
+
77
+
The newly created repository will start with a new ("flattened") history, only one commit, and not
0 commit comments