diff --git a/content/basics.md b/content/basics.md
index 5544c301..1ab64e68 100644
--- a/content/basics.md
+++ b/content/basics.md
@@ -19,15 +19,15 @@
- Every time we **commit** a snapshot, Git records a snapshot of the **entire project**, saves it, and assigns it a version.
- These snapshots are kept inside a sub-folder called `.git`.
- If we remove `.git`, we remove the repository and history (but keep the working directory!).
-- `.git` uses relative paths - you can move the whole thing somewhere else and it will still work
-- Git doesn't do anything unless you ask it to (it does not record anything automatically).
+- `.git` uses relative paths - you can move the whole thing somewhere else and it will still work.
+- Git doesn't do anything unless you ask it to (it **does not record anything automatically**).
- Multiple interfaces to Git exist (command line, graphical interfaces, web interfaces).
## Recording a snapshot with Git
- Git takes snapshots only if we request it.
-- We will record changes always in two steps (we will later explain why this is a recommended practice).
+- We will record changes in two steps (we will later explain why this is a recommended practice).
- Example (we don't need to type yet):
```console
@@ -38,7 +38,7 @@
$ git commit
```
-- We first focus (`git add`, we "stage" the change), then shoot (`git commit`):
+- We first focus (`git add`, we "stage" the change), then record (`git commit`):
```{figure} img/git_stage_commit.svg
:alt: Git staging
@@ -55,39 +55,39 @@ shutter at the end)
```
-## Before we start we need to configure Git
-
-If you haven't already configured Git, please follow the instructions in the
-[installation instructions](https://coderefinery.github.io/installation/shell-and-git/#configuration).
-
-````{instructor-note}
-Instructors might want to show how to set email address and editor:
+## Configuring Git
+Before we start we need to configure Git.
+This is also part of the
+[installation instructions](https://coderefinery.github.io/installation/shell-and-git/#configuration)
+but we need to make sure we all have
+set name, email address, editor, and
+default branch:
```console
$ git config --global user.name "Your Name"
$ git config --global user.email yourname@example.com
$ git config --global core.editor nano
+$ git config --global init.defaultBranch main
```
Verify with:
```console
$ git config --list
```
-````
+
+```{instructor-note}
+Instructors, give learners enough time to do the above configuration steps.
+```
## Type-along: Tracking a guacamole recipe with Git
We will learn how to initialize a Git repository, how to track changes, and how
-to make delicious guacamole!
+to make delicious guacamole (inspiration: suggestion by B. Smith in a discussion in the Carpentries mailing list)!
-This example is inspired by [Byron Smith](http://blog.byronjsmith.com) (based
-on a discussion in the Carpentries mailing list).
The motivation for taking a cooking recipe instead of a program is that everybody can relate to cooking
but not everybody may be able to relate to a program written in e.g. Python or another language.
-Let us start.
-
```{instructor-note}
Instructors, please encourage now that participants type along.
```
@@ -107,7 +107,7 @@ We will use `git status` a lot to check out what is going on:
```console
$ git status
-On branch master
+On branch main
No commits yet
@@ -143,7 +143,7 @@ do when you are trying to figure out what to do next:
```console
$ git status
-On branch master
+On branch main
No commits yet
@@ -167,7 +167,7 @@ $ git add ingredients.txt
$ git add instructions.txt
$ git status
-On branch master
+On branch main
Initial commit
@@ -185,7 +185,7 @@ Let us now commit the change to the repository:
```console
$ git commit -m "adding ingredients and instructions"
-[master (root-commit) aa243ea] adding ingredients and instructions
+[main (root-commit) aa243ea] adding ingredients and instructions
2 files changed, 8 insertions(+)
create mode 100644 ingredients.txt
create mode 100644 instructions.txt
diff --git a/content/branches.md b/content/branches.md
index 8c2a57e8..1d00e381 100644
--- a/content/branches.md
+++ b/content/branches.md
@@ -26,7 +26,7 @@ Linear Git repository.
```
- Commits are depicted here as little boxes with abbreviated hashes.
-- Here the branch `master` points to a commit.
+- Here the branch `main` points to a commit.
- "HEAD" is the current position (remember the recording head of tape recorders?).
- When we talk about branches, we often mean all parent commits, not only the commit pointed to.
@@ -59,8 +59,8 @@ Isolated tracks of work.
```
- We see branching points and merging points.
-- Main line development is often called `master` or `main`.
-- Other than this convention there is nothing special about `master` or `main`, it is just a branch.
+- Main line development is often called `main` or `master`.
+- Other than this convention there is nothing special about `main` or `master`, it is just a branch.
- Commits form a directed acyclic graph (we have left out the arrows to avoid confusion about the time arrow).
A group of commits that create a single narrative are called a **branch**.
@@ -95,18 +95,18 @@ Let us inspect the project history using the `git graph` alias:
```console
$ git graph
-* dd4472c (HEAD -> master) we should not forget to enjoy
+* dd4472c (HEAD -> main) we should not forget to enjoy
* 2bb9bb4 add half an onion
* 2d79e7e adding ingredients and instructions
```
- We have three commits and only
- one development line (branch) and this branch is called `master`.
+ one development line (branch) and this branch is called `main`.
- Commits are states characterized by a 40-character hash (checksum).
- `git graph` print abbreviations of these checksums.
- **Branches are pointers that point to a commit.**
-- Branch `master` points to commit `dd4472c8093b7bbcdaa15e3066da6ca77fcabadd`.
-- `HEAD` is another pointer, it points to where we are right now (currently `master`)
+- Branch `main` points to commit `dd4472c8093b7bbcdaa15e3066da6ca77fcabadd`.
+- `HEAD` is another pointer, it points to where we are right now (currently `main`)
### On which branch are we?
@@ -116,11 +116,11 @@ To see where we are (where HEAD points to) use `git branch`:
```console
$ git branch
-* master
+* main
```
- This command shows where we are, it does not create a branch.
-- There is only `master` and we are on `master` (star represents the `HEAD`).
+- There is only `main` and we are on `main` (star represents the `HEAD`).
In the following we will learn how to create branches,
how to switch between them, how to merge branches,
@@ -136,7 +136,7 @@ We do the following part together. Encourage participants to type along.
Let's create a branch called `experiment` where we add cilantro to `ingredients.txt`.
```console
-$ git branch experiment master # creates branch "experiment" from master
+$ git branch experiment main # creates branch "experiment" from "main"
$ git checkout experiment # switch to branch "experiment"
$ git branch # list all local branches and show on which branch we are
```
@@ -148,7 +148,7 @@ $ git branch # list all local branches and show on which bra
$ git branch
* experiment
- master
+ main
```
- Then add 2 tbsp cilantro **on top** of the `ingredients.txt`:
@@ -177,12 +177,12 @@ $ git graph
* 6feb49d (HEAD -> experiment) maybe little bit less cilantro
* 7cf6d8c let us try with some cilantro
-* dd4472c (master) we should not forget to enjoy
+* dd4472c (main) we should not forget to enjoy
* 2bb9bb4 add half an onion
* 2d79e7e adding ingredients and instructions
```
-- The branch `experiment` is two commits ahead of `master`.
+- The branch `experiment` is two commits ahead of `main`.
- We commit our changes to this branch.
@@ -195,13 +195,13 @@ $ git graph
We will use this in the next section, to practice
merging. **The goal of the exercise is to end up with 3 branches**.
- - Change to the branch `master`.
+ - Change to the branch `main`.
- Create another branch called `less-salt`
- - Note! makes sure you are on master branch when you create the less-salt branch
- - A safer way would be to explicitly mention to create from the master branch
+ - Note! makes sure you are on main branch when you create the less-salt branch
+ - A safer way would be to explicitly mention to create from the main branch
as shown below:
```console
- $ git branch less-salt master
+ $ git branch less-salt main
```
- Where you reduce the amount of salt.
- Commit your changes to the `less-salt` branch.
@@ -215,7 +215,7 @@ $ git graph
experiment
* less-salt
- master
+ main
$ git graph
@@ -223,7 +223,7 @@ $ git graph
| * 6feb49d (experiment) maybe little bit less cilantro
| * 7cf6d8c let us try with some cilantro
|/
- * dd4472c (master) we should not forget to enjoy
+ * dd4472c (main) we should not forget to enjoy
* 2bb9bb4 add half an onion
* 2d79e7e adding ingredients and instructions
```
@@ -233,8 +233,8 @@ $ git graph
```{figure} img/gitink/git-branch-2.svg
```
- - Now switch to `master`.
- - Add and commit the following `README.md` to `master`:
+ - Now switch to `main`.
+ - Add and commit the following `README.md` to `main`:
```markdown
# Guacamole recipe
@@ -247,7 +247,7 @@ $ git graph
```console
$ git graph
- * 40fbb90 (HEAD -> master) draft a readme
+ * 40fbb90 (HEAD -> main) draft a readme
| * bf59be6 (less-salt) reduce amount of salt
|/
| * 6feb49d (experiment) maybe little bit less cilantro
@@ -272,7 +272,7 @@ We do the rest as type-along. Instructors, encourage learners to type-along.
```
It turned out that our experiment with cilantro was a good idea.
-Our goal now is to merge `experiment` into `master`.
+Our goal now is to merge `experiment` into `main`.
````{admonition} If you got stuck in the above exercises or joined later
**If you got stuck in the above exercises or joined later**,
@@ -287,7 +287,7 @@ Our goal now is to merge `experiment` into `master`.
$ git checkout experiment
$ git checkout less-salt
- $ git checkout master
+ $ git checkout main
$ git remote remove origin
@@ -307,10 +307,10 @@ $ git branch
experiment
less-salt
-* master
+* main
```
-Then we merge `experiment` into `master`:
+Then we merge `experiment` into `main`:
```console
$ git merge experiment
@@ -324,7 +324,7 @@ We can verify the result in the terminal:
```console
$ git graph
-* c43b24c (HEAD -> master) Merge branch 'experiment'
+* c43b24c (HEAD -> main) Merge branch 'experiment'
|\
| * 6feb49d (experiment) maybe little bit less cilantro
| * 7cf6d8c let us try with some cilantro
@@ -348,14 +348,14 @@ To view the branches that are merged into the current branch we can use the comm
$ git branch --merged
experiment
-* master
+* main
```
We are also happy with the work on the `less-salt` branch. Let us merge that
-one, too, into `master`:
+one, too, into `main`:
```console
-$ git branch # make sure you are on master
+$ git branch # make sure you are on main
$ git merge less-salt
```
@@ -370,7 +370,7 @@ We can verify the result in the terminal:
```console
$ git graph
-* 4f00317 (HEAD -> master) Merge branch 'less-salt'
+* 4f00317 (HEAD -> main) Merge branch 'less-salt'
|\
| * bf59be6 (less-salt) reduce amount of salt
* | c43b24c Merge branch 'experiment'
@@ -412,7 +412,7 @@ $ git branch --merged
experiment
less-salt
-* master
+* main
```
This means we can delete the branches:
@@ -437,7 +437,7 @@ Compare in the terminal:
```console
$ git graph
-* 4f00317 (HEAD -> master) Merge branch 'less-salt'
+* 4f00317 (HEAD -> main) Merge branch 'less-salt'
|\
| * bf59be6 reduce amount of salt
* | c43b24c Merge branch 'experiment'
@@ -471,18 +471,18 @@ few months later. If you give them a go, keep in mind that you might run into co
which we will learn to resolve in the next section.
````{exercise} (optional) Branch-2: Perform a fast-forward merge
-1. Create a new branch from `master` and switch to it.
+1. Create a new branch from `main` and switch to it.
2. Create a couple of commits on the new branch (for instance edit `README.md`):
```{figure} img/gitink/git-pre-ff.svg
```
-3. Now switch to `master`.
-4. Merge the new branch to `master`.
+3. Now switch to `main`.
+4. Merge the new branch to `main`.
5. Examine the result with `git graph`.
6. Have you expected the result? Discuss what you see.
```{solution}
You will see that in this case no merge commit was created and Git merged the
- two branches by moving (fast-forwarding) the "master" branch (label) three
+ two branches by moving (fast-forwarding) the "main" branch (label) three
commits forward.
This was possible since one branch is the ancestor of the other and their
@@ -498,9 +498,9 @@ Rebasing means that the new commits are *replayed* on top of another branch
(instead of creating an explicit merge commit).
**Note that rebasing changes history and should not be done on public commits!**
1. Create a new branch, and make a couple of commits on it.
-2. Switch back to `master`, and make a couple of commits on it.
+2. Switch back to `main`, and make a couple of commits on it.
3. Inspect the situation with `git graph`.
-4. Now rebase the new branch on top of `master` by first switching to the new branch, and then `git rebase master`.
+4. Now rebase the new branch on top of `main` by first switching to the new branch, and then `git rebase main`.
5. Inspect again the situation with `git graph`. Notice that the commit hashes have changed - think about why!
```{solution}
@@ -509,7 +509,7 @@ Rebasing means that the new commits are *replayed* on top of another branch
- All the commit hashes that were on the branch that got rebased, have
changed. This also demonstrates that `git rebase` is a command that alters
history. The commit history looks as if the rebased commits were all done
- after the `master` commits.
+ after the `main` commits.
```
````
@@ -576,8 +576,8 @@ With this there are two typical workflows:
```console
$ git checkout -b new-feature # create branch, switch to it
$ git commit # work, work, work, ..., and test
-$ git checkout master # once feature is ready, switch to master
-$ git merge new-feature # merge work to master
+$ git checkout main # once feature is ready, switch to main
+$ git merge new-feature # merge work to main
$ git branch -d new-feature # remove branch
```
@@ -586,11 +586,11 @@ Or you want some throw-away branch for debugging:
```console
$ git checkout -b wild-idea # create branch, switch to it, work, work, work ...
-$ git checkout master # realize it was a bad idea, back to master
+$ git checkout main # realize it was a bad idea, back to main
$ git branch -D wild-idea # it is gone, off to a new idea
```
-No problem: we worked on a branch, branch is deleted, `master` is clean.
+No problem: we worked on a branch, branch is deleted, `main` is clean.
````{challenge} Branch-4: Test your understanding
Which of the following combos (one or more) creates a new branch and makes a commit to it?
diff --git a/content/conflicts.md b/content/conflicts.md
index 59c905fa..aa1bf53b 100644
--- a/content/conflicts.md
+++ b/content/conflicts.md
@@ -120,17 +120,17 @@ We will make two branches, make two conflicting changes (both increase and
decrease the amount of cilantro), and later we will try to merge them
together.
-- Create two branches from `master`: one called `like-cilantro`, one called `dislike-cilantro`:
+- Create two branches from `main`: one called `like-cilantro`, one called `dislike-cilantro`:
```console
- $ git branch like-cilantro master
- $ git branch dislike-cilantro master
+ $ git branch like-cilantro main
+ $ git branch dislike-cilantro main
```
- On the two branches make **different modifications** to the amount of the **same ingredient**:
- On the branch `like-cilantro` we have the following change:
```console
- $ git diff master like-cilantro
+ $ git diff main like-cilantro
```
```diff
@@ -148,7 +148,7 @@ together.
- And on the branch `dislike-cilantro` we have the following change:
```console
- $ git diff master dislike-cilantro
+ $ git diff main dislike-cilantro
```
```diff
@@ -168,12 +168,12 @@ together.
## Merging conflicting changes
What do you expect will happen when we try to merge these two branches into
-master?
+main?
The first merge will work:
```console
-$ git checkout master
+$ git checkout main
$ git status
$ git merge like-cilantro
@@ -202,7 +202,7 @@ emphasize-lines: 11
---
$ git status
-On branch master
+On branch main
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
@@ -308,7 +308,7 @@ different ingredient.
4. What happens if you apply the same modification on both branches?
5. If you create a branch `like-avocados`, commit a change, then from this
branch create another banch `dislike-avocados`, commit again, and try to
- merge both branches into `master` you will not see a conflict. Can you
+ merge both branches into `main` you will not see a conflict. Can you
explain, why it is different this time?
```{solution}
4: No conflict in this case if the change is the same.
diff --git a/content/img/gitink/Makefile b/content/img/gitink/Makefile
index 1a4a89ff..2666264d 100644
--- a/content/img/gitink/Makefile
+++ b/content/img/gitink/Makefile
@@ -6,5 +6,5 @@ all: $(OBJS)
%.svg: %.txt
gitink --in-file=$< --time-direction=90 --scale=1.0 > $@
-clean:
+clean:
rm *.svg
diff --git a/content/img/gitink/git-branch-1.svg b/content/img/gitink/git-branch-1.svg
index aaaa8a04..71c7fbf0 100644
--- a/content/img/gitink/git-branch-1.svg
+++ b/content/img/gitink/git-branch-1.svg
@@ -8,7 +8,7 @@
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="168.0"
+ width="160.0"
height="160.0"
id="svg2"
version="1.1"
@@ -153,9 +153,9 @@
stroke-miterlimit:4;
stroke-opacity:1.0;
stroke-dasharray:none"
- width="64.0"
+ width="48.0"
height="30.0"
- x="104.0"
+ x="112.0"
y="-65.0"
ry="0.0" />
master
+ x="119.5"
+ y="-44.5">main
master
+ x="119.5"
+ y="-44.5">main
master
+ x="179.5"
+ y="-104.5">main
master
+ x="359.5"
+ y="145.5">main
master
+ x="299.5"
+ y="-104.5">main
master
+ x="359.5"
+ y="145.5">main
master
+ x="359.5"
+ y="145.5">main
diff --git a/content/img/gitink/git-pre-ff.txt b/content/img/gitink/git-pre-ff.txt
index 56881f65..03659ece 100644
--- a/content/img/gitink/git-pre-ff.txt
+++ b/content/img/gitink/git-pre-ff.txt
@@ -5,4 +5,4 @@ m1----m2----m3----e1----e2 \ [update-readme,HEAD]
\ \ |
l1-------------m6----n1----n2----n3
|
- [master]
+ [main]
diff --git a/content/recovering.md b/content/recovering.md
index b5d40844..335a97b4 100644
--- a/content/recovering.md
+++ b/content/recovering.md
@@ -66,7 +66,7 @@ If you have staged changes, you have at least two options to undo the staging:
```console
$ git log --oneline
- f960dd3 (HEAD -> master) not sure this is a good idea
+ f960dd3 (HEAD -> main) not sure this is a good idea
dd4472c we should not forget to enjoy
2bb9bb4 add half an onion
2d79e7e adding ingredients and instructions
@@ -82,7 +82,7 @@ The old commit remains in the history:
```console
$ git log --oneline
-d62ad3e (HEAD -> master) Revert "not sure this is a good idea"
+d62ad3e (HEAD -> main) Revert "not sure this is a good idea"
f960dd3 not sure this is a good idea
dd4472c we should not forget to enjoy
2bb9bb4 add half an onion
@@ -167,7 +167,7 @@ point in the past.
```console
$ git log --oneline
- d62ad3e (HEAD -> master) Revert "not sure this is a good idea"
+ d62ad3e (HEAD -> main) Revert "not sure this is a good idea"
f960dd3 not sure this is a good idea
dd4472c we should not forget to enjoy
2bb9bb4 add half an onion
@@ -179,7 +179,7 @@ point in the past.
$ git log --oneline
- dd4472c (HEAD -> master) we should not forget to enjoy
+ dd4472c (HEAD -> main) we should not forget to enjoy
2bb9bb4 add half an onion
2d79e7e adding ingredients and instructions
```
diff --git a/content/reference.md b/content/reference.md
index 2a884fab..6547f32b 100644
--- a/content/reference.md
+++ b/content/reference.md
@@ -18,8 +18,13 @@
* **HEAD**: Pointer to the most recent commit on the current branch.
* **remote**: Roughly, another server that holds .git.
* **origin**: Default name for a remote repository.
-* **master**: Default name for main branch. Depending on the configuration and service,
+* **master**: Default name for main branch on Git. Depending on the configuration and service,
the default branch is sometimes **main**.
+ In this lesson we configure Git so that the default branch is
+ called **main** to be more consistent with GitHub and GitLab.
+* **main**: Default name for main branch on GitLab and GitHub.
+ In this lesson we configure Git so that the default branch is
+ called **main** to be more consistent with GitHub and GitLab.
## Commands we use
diff --git a/content/remotes.md b/content/remotes.md
index 35a0027f..ab13e137 100644
--- a/content/remotes.md
+++ b/content/remotes.md
@@ -187,12 +187,6 @@ online!**
What just happened? **Think of publishing a repository as uploading the `.git` part online**.
-```{note}
-We could have pushed the `master` branch using `$ git push origin master`,
-without renaming it to `main`. Here we chose to rename the branch to `main` to
-closely follow the instructions from the GitHub web interface.
-```
-
---
## Cloning a repository
diff --git a/content/under-the-hood.md b/content/under-the-hood.md
index da8d45ce..148134ae 100644
--- a/content/under-the-hood.md
+++ b/content/under-the-hood.md
@@ -102,12 +102,12 @@ Let us lift the hood and create few branches manually. The
goal of this exercise is to hopefully create an "aha" moment and provide us a
good understanding of the underlying model.
-We are starting from the `master` branch and create an `idea` branch:
+We are starting from the `main` branch and create an `idea` branch:
```console
$ git status
-On branch master
+On branch main
nothing to commit, working tree clean
```
@@ -121,7 +121,7 @@ Switched to a new branch 'idea'
$ git branch
* idea
- master
+ main
```
Now let us go in:
@@ -133,7 +133,7 @@ $ ls -l
total 8
-rw------- 1 bast users 41 May 7 11:47 idea
--rw------- 1 bast users 41 May 7 11:47 master
+-rw------- 1 bast users 41 May 7 11:47 main
```
Let us check what the `idea` file looks like
@@ -181,7 +181,7 @@ $ git branch
* idea-3
idea-4
idea-5
- master
+ main
```
```{discussion}