From 9a6c83bbdc2c3dc47e1f087928d2a3118e2f3755 Mon Sep 17 00:00:00 2001 From: juckerj Date: Mon, 19 Sep 2022 11:40:38 +0200 Subject: [PATCH 01/23] move beginners course --- {Exercise_1 => beginner/Exercise_1}/Exercise_1.ipynb | 0 {Exercise_2 => beginner/Exercise_2}/Exercise_2.ipynb | 0 {Exercise_3 => beginner/Exercise_3}/Exercise_3.ipynb | 0 {Exercise_4 => beginner/Exercise_4}/Exercise_4.ipynb | 0 {Exercise_5 => beginner/Exercise_5}/Exercise_5.ipynb | 0 {Exercise_6 => beginner/Exercise_6}/Exercise_6.ipynb | 0 {Exercise_7 => beginner/Exercise_7}/Exercise_7.ipynb | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename {Exercise_1 => beginner/Exercise_1}/Exercise_1.ipynb (100%) rename {Exercise_2 => beginner/Exercise_2}/Exercise_2.ipynb (100%) rename {Exercise_3 => beginner/Exercise_3}/Exercise_3.ipynb (100%) rename {Exercise_4 => beginner/Exercise_4}/Exercise_4.ipynb (100%) rename {Exercise_5 => beginner/Exercise_5}/Exercise_5.ipynb (100%) rename {Exercise_6 => beginner/Exercise_6}/Exercise_6.ipynb (100%) rename {Exercise_7 => beginner/Exercise_7}/Exercise_7.ipynb (100%) diff --git a/Exercise_1/Exercise_1.ipynb b/beginner/Exercise_1/Exercise_1.ipynb similarity index 100% rename from Exercise_1/Exercise_1.ipynb rename to beginner/Exercise_1/Exercise_1.ipynb diff --git a/Exercise_2/Exercise_2.ipynb b/beginner/Exercise_2/Exercise_2.ipynb similarity index 100% rename from Exercise_2/Exercise_2.ipynb rename to beginner/Exercise_2/Exercise_2.ipynb diff --git a/Exercise_3/Exercise_3.ipynb b/beginner/Exercise_3/Exercise_3.ipynb similarity index 100% rename from Exercise_3/Exercise_3.ipynb rename to beginner/Exercise_3/Exercise_3.ipynb diff --git a/Exercise_4/Exercise_4.ipynb b/beginner/Exercise_4/Exercise_4.ipynb similarity index 100% rename from Exercise_4/Exercise_4.ipynb rename to beginner/Exercise_4/Exercise_4.ipynb diff --git a/Exercise_5/Exercise_5.ipynb b/beginner/Exercise_5/Exercise_5.ipynb similarity index 100% rename from Exercise_5/Exercise_5.ipynb rename to beginner/Exercise_5/Exercise_5.ipynb diff --git a/Exercise_6/Exercise_6.ipynb b/beginner/Exercise_6/Exercise_6.ipynb similarity index 100% rename from Exercise_6/Exercise_6.ipynb rename to beginner/Exercise_6/Exercise_6.ipynb diff --git a/Exercise_7/Exercise_7.ipynb b/beginner/Exercise_7/Exercise_7.ipynb similarity index 100% rename from Exercise_7/Exercise_7.ipynb rename to beginner/Exercise_7/Exercise_7.ipynb From bc7e1a33f091c1282380c62b9f3fec1df22bc400 Mon Sep 17 00:00:00 2001 From: juckerj Date: Mon, 19 Sep 2022 11:44:07 +0200 Subject: [PATCH 02/23] move more files --- .../Unix_Commands.ipynb | 0 .../Markdowns}/Exercise_1.md | 0 .../Markdowns}/Exercise_2.md | 0 .../Markdowns}/Exercise_3.md | 0 .../Markdowns}/Exercise_4.md | 0 .../Markdowns}/Exercise_5.md | 0 .../Markdowns}/Exercise_6.md | 0 .../Markdowns}/Exercise_7.md | 0 beginner/README.md | 47 ++++++++++++++++++ .../convert_to_markdown | 0 {images => beginner/images}/Edit_file_PR.png | Bin {images => beginner/images}/Fork.png | Bin .../images}/Forked_Repo_view.png | Bin {images => beginner/images}/Open_Terminal.png | Bin .../schedule_beginners_course_June_2022.md | 0 15 files changed, 47 insertions(+) rename Unix_Commands.ipynb => advanced/Unix_Commands.ipynb (100%) rename {Markdowns => beginner/Markdowns}/Exercise_1.md (100%) rename {Markdowns => beginner/Markdowns}/Exercise_2.md (100%) rename {Markdowns => beginner/Markdowns}/Exercise_3.md (100%) rename {Markdowns => beginner/Markdowns}/Exercise_4.md (100%) rename {Markdowns => beginner/Markdowns}/Exercise_5.md (100%) rename {Markdowns => beginner/Markdowns}/Exercise_6.md (100%) rename {Markdowns => beginner/Markdowns}/Exercise_7.md (100%) create mode 100644 beginner/README.md rename convert_to_markdown => beginner/convert_to_markdown (100%) rename {images => beginner/images}/Edit_file_PR.png (100%) rename {images => beginner/images}/Fork.png (100%) rename {images => beginner/images}/Forked_Repo_view.png (100%) rename {images => beginner/images}/Open_Terminal.png (100%) rename schedule_beginners_course_June_2022.md => beginner/schedule_beginners_course_June_2022.md (100%) diff --git a/Unix_Commands.ipynb b/advanced/Unix_Commands.ipynb similarity index 100% rename from Unix_Commands.ipynb rename to advanced/Unix_Commands.ipynb diff --git a/Markdowns/Exercise_1.md b/beginner/Markdowns/Exercise_1.md similarity index 100% rename from Markdowns/Exercise_1.md rename to beginner/Markdowns/Exercise_1.md diff --git a/Markdowns/Exercise_2.md b/beginner/Markdowns/Exercise_2.md similarity index 100% rename from Markdowns/Exercise_2.md rename to beginner/Markdowns/Exercise_2.md diff --git a/Markdowns/Exercise_3.md b/beginner/Markdowns/Exercise_3.md similarity index 100% rename from Markdowns/Exercise_3.md rename to beginner/Markdowns/Exercise_3.md diff --git a/Markdowns/Exercise_4.md b/beginner/Markdowns/Exercise_4.md similarity index 100% rename from Markdowns/Exercise_4.md rename to beginner/Markdowns/Exercise_4.md diff --git a/Markdowns/Exercise_5.md b/beginner/Markdowns/Exercise_5.md similarity index 100% rename from Markdowns/Exercise_5.md rename to beginner/Markdowns/Exercise_5.md diff --git a/Markdowns/Exercise_6.md b/beginner/Markdowns/Exercise_6.md similarity index 100% rename from Markdowns/Exercise_6.md rename to beginner/Markdowns/Exercise_6.md diff --git a/Markdowns/Exercise_7.md b/beginner/Markdowns/Exercise_7.md similarity index 100% rename from Markdowns/Exercise_7.md rename to beginner/Markdowns/Exercise_7.md diff --git a/beginner/README.md b/beginner/README.md new file mode 100644 index 0000000..1f6d7c7 --- /dev/null +++ b/beginner/README.md @@ -0,0 +1,47 @@ +# Git Course for Beginners +This repository contains the exercises for the C2SM Git Workshop "Git for Beginners". +Feel free to download the material to practice and enhance your Git skills. + +The corresponding [slides of this course](https://wiki.c2sm.ethz.ch/CM/WorkshopBestPractices2013) can be found +at the C2SM wiki. + +A Markdown version of the .ipynb files for each exercise is located in the [Markdowns folder](Markdowns). + +We recommend to make use of the convienient way of doing the exercises with Jupyter Notebook itself. +For installation instructions see section below. + +## How to run the exercises +First of all, you need a Git installation on your computer. +To do so, please follow the [instructions from GitHub](https://github.com/git-guides/install-git). + +> **_Important note:_** You must have at least Git 2.28 (released 27 July 2020) installed. +> You can check your Git version by typing `git --version` in your terminal. + +Second, you need a Python installation as well. +We provide you here with [instructions from realpython](https://realpython.com/installing-python/), +but of course many other instruction will do it as well. + +Third, you need some non-standard python packages, namely: + - jupyterlab + - bash_kernel + +To install these two packages, execute the following command in your terminal: +``` +python -m venv git-course_env +source git-course_env/bin/activate +pip install -r requirements.txt +``` +On some machines an additional step is necessary: +``` +python -m bash_kernel.install +``` + +Finally, you can start with the exercises by running: +``` +jupyter notebook +``` +This command opens the Jupyter Notebook interface in your browser. +If it does not open automatically, you have to copy and paste the URL manually. +In that case, please follow the instructions in your terminal. + +**Have fun!** diff --git a/convert_to_markdown b/beginner/convert_to_markdown similarity index 100% rename from convert_to_markdown rename to beginner/convert_to_markdown diff --git a/images/Edit_file_PR.png b/beginner/images/Edit_file_PR.png similarity index 100% rename from images/Edit_file_PR.png rename to beginner/images/Edit_file_PR.png diff --git a/images/Fork.png b/beginner/images/Fork.png similarity index 100% rename from images/Fork.png rename to beginner/images/Fork.png diff --git a/images/Forked_Repo_view.png b/beginner/images/Forked_Repo_view.png similarity index 100% rename from images/Forked_Repo_view.png rename to beginner/images/Forked_Repo_view.png diff --git a/images/Open_Terminal.png b/beginner/images/Open_Terminal.png similarity index 100% rename from images/Open_Terminal.png rename to beginner/images/Open_Terminal.png diff --git a/schedule_beginners_course_June_2022.md b/beginner/schedule_beginners_course_June_2022.md similarity index 100% rename from schedule_beginners_course_June_2022.md rename to beginner/schedule_beginners_course_June_2022.md From ef4497fe4d209f6c5f4f64dd43b0f8fe334b8b27 Mon Sep 17 00:00:00 2001 From: juckerj <39263956+jonasjucker@users.noreply.github.com> Date: Mon, 19 Sep 2022 11:45:56 +0200 Subject: [PATCH 03/23] Update README.md --- beginner/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beginner/README.md b/beginner/README.md index 1f6d7c7..2d2c53d 100644 --- a/beginner/README.md +++ b/beginner/README.md @@ -1,5 +1,5 @@ # Git Course for Beginners -This repository contains the exercises for the C2SM Git Workshop "Git for Beginners". +This folder contains the exercises for the C2SM Git Workshop "Git for Beginners". Feel free to download the material to practice and enhance your Git skills. The corresponding [slides of this course](https://wiki.c2sm.ethz.ch/CM/WorkshopBestPractices2013) can be found From c4fb06c9e5402115950522eb5ca1000554107003 Mon Sep 17 00:00:00 2001 From: juckerj Date: Mon, 19 Sep 2022 11:49:26 +0200 Subject: [PATCH 04/23] completely separate the two courses --- {examples => beginner/examples}/schedule_day1 | 0 {examples => beginner/examples}/schedule_day2 | 0 helpers.sh => beginner/helpers.sh | 0 requirements.txt => beginner/requirements.txt | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {examples => beginner/examples}/schedule_day1 (100%) rename {examples => beginner/examples}/schedule_day2 (100%) rename helpers.sh => beginner/helpers.sh (100%) rename requirements.txt => beginner/requirements.txt (100%) diff --git a/examples/schedule_day1 b/beginner/examples/schedule_day1 similarity index 100% rename from examples/schedule_day1 rename to beginner/examples/schedule_day1 diff --git a/examples/schedule_day2 b/beginner/examples/schedule_day2 similarity index 100% rename from examples/schedule_day2 rename to beginner/examples/schedule_day2 diff --git a/helpers.sh b/beginner/helpers.sh similarity index 100% rename from helpers.sh rename to beginner/helpers.sh diff --git a/requirements.txt b/beginner/requirements.txt similarity index 100% rename from requirements.txt rename to beginner/requirements.txt From 29eba9e970234fcc1f81c32f3f2e82667c6dda89 Mon Sep 17 00:00:00 2001 From: juckerj <39263956+jonasjucker@users.noreply.github.com> Date: Mon, 19 Sep 2022 12:01:53 +0200 Subject: [PATCH 05/23] Update Exercise_3.md --- advanced/Exercise_3.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/advanced/Exercise_3.md b/advanced/Exercise_3.md index 5259d3c..eb571ca 100644 --- a/advanced/Exercise_3.md +++ b/advanced/Exercise_3.md @@ -12,7 +12,7 @@ In this exercise, you will first use a provided script to generate a simple git ## Initialize the git repository -Use the helper scripts provided in https://www.github.com/C2SM/git-course to set up a simple git repository. +Use the [helper scripts](helpers.sh) provided in folder [advanced](../advanced) to set up a simple git repository. First, clone the git-course repository if you have not already done so in Exercise 1. @@ -35,6 +35,7 @@ git config --global init.defaultBranch main Source the file containing the helper scripts: `helpers.sh` ```plaintext +cd advanced source helpers.sh ``` Run the `init_advanced_repo` script. This script will create a folder at the same level as the git-course repository containing a simple git repository called `conference_planning`. From da76bab4ea721bf4ab4617707c3214c86088a913 Mon Sep 17 00:00:00 2001 From: juckerj <39263956+jonasjucker@users.noreply.github.com> Date: Mon, 19 Sep 2022 12:05:59 +0200 Subject: [PATCH 06/23] Update Exercise_3.md --- advanced/Exercise_3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_3.md b/advanced/Exercise_3.md index eb571ca..bec3158 100644 --- a/advanced/Exercise_3.md +++ b/advanced/Exercise_3.md @@ -1,6 +1,6 @@ # Exercise 3 - Ignoring files -In this exercise, you will first use a provided script to generate a simple git repository containing materials for planning a conference. You will then create a README file for the conference planning repository using the Markdown language. Then you will generate an HTML README file, and finally create a `.gitignore` file for the repository. This exercise is closely adapted from [this website](https://oesa.pages.ufz.de/git-exercises/exercise-5.html). +In this exercise, you will first use a provided script to generate a simple git repository containing materials for planning a conference. You will then create a README file for the conference planning repository using the Markdown language. Then you will generate an HTML README file, and finally create a `.gitignore` file for the repository. This exercise is closely adapted from [OESA Git Workshop](https://oesa.pages.ufz.de/git-exercises/exercise-5.html). * [Initialize the git repository](#initialize) From a53f66499acbc9ada0513ed6fe526f1008cd7e0b Mon Sep 17 00:00:00 2001 From: juckerj Date: Mon, 19 Sep 2022 12:06:35 +0200 Subject: [PATCH 07/23] more separation --- advanced/helpers.sh | 179 +++++++++++++++++++++ {advanced => beginner}/Unix_Commands.ipynb | 0 2 files changed, 179 insertions(+) create mode 100755 advanced/helpers.sh rename {advanced => beginner}/Unix_Commands.ipynb (100%) diff --git a/advanced/helpers.sh b/advanced/helpers.sh new file mode 100755 index 0000000..40fcf6b --- /dev/null +++ b/advanced/helpers.sh @@ -0,0 +1,179 @@ +#!/bin/bash + +if [[ ! -z $dir_at_startup ]]; then + echo "You cannot source this file twice" +else + dir_at_startup=$(pwd) +fi + +reset () { + echo "Go back to $dir_at_startup" + cd $dir_at_startup + + echo "Restore clean working directory" + mkdir -p work + rm -rf work + mkdir work + cd work + + echo "Here we go again!" +} + +init_exercise () { + cd $dir_at_startup + mkdir -p work + cd work + echo "Working directory prepared" +} + +init_directory_with_empty_file () { + mkdir -p conference_planning + cd conference_planning + touch conference_schedule.txt +} + +init_simple_repo () { + mkdir -p conference_planning + cd conference_planning + git init + cp ../../../examples/schedule_day1 . + cp ../../../examples/schedule_day2 . + + git add schedule_day1 && git commit -m "Add schedule_day1" + git add schedule_day2 && git commit -m "Add schedule_day2" + + ed -s schedule_day1 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null + ed -s schedule_day2 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null + git add * && git commit -m "Add poster sessions in the morning" + + ed -s schedule_day1 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null + ed -s schedule_day2 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null + git add * && git commit -m "Add coffee break" + + echo "" + echo "Your commits so far:" + echo "" + git log + + echo"" + echo "Your schedules:" + echo"" + ls +} + +init_simple_repo_remote () { + mkdir -p conference_planning + cd conference_planning + git init + cp ../../../examples/schedule_day1 . + cp ../../../examples/schedule_day2 . + + git add schedule_day1 && git commit -m "Add schedule_day1" + git add schedule_day2 && git commit -m "Add schedule_day2" + + ed -s schedule_day1 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null + ed -s schedule_day2 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null + git add * && git commit -m "Add poster sessions in the morning" + + ed -s schedule_day1 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null + ed -s schedule_day2 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null + git add * && git commit -m "Add coffee breaks" + + cd .. + git clone conference_planning conference_planning_remote + cd conference_planning_remote + git switch -c "updated_schedules" + ed -s schedule_day1 <<< $'/break/\na\n11:15-12:15: Talk professor A.\n.\nw\nq' > /dev/null + ed -s schedule_day2 <<< $'/break/\na\n11:15-12:15: Talk professor B.\n.\nw\nq' > /dev/null + git add * && git commit -m "update schedules" + git switch main + + cd ../conference_planning + ls +} + +init_broken_repo () { + init_simple_repo &> /dev/null + + ed -s schedule_day1 <<< $'/break/\na\n11:15-12:15: Workshop ice crystal formation\n.\nw\nq' > /dev/null + ed -s schedule_day2 <<< $'/break/\na\n11:15-12:12: Workshop secondary ice\n.\nw\nq' > /dev/null + git add * && git commit -m "Add workshops" + + sed 's/Poster session/Talk professor C./g' schedule_day1 > schedule_day1_tmp + sed 's/Poster session/Talk professor D./g' schedule_day2 > schedule_day2_tmp + + mv -f schedule_day1_tmp schedule_day1 + mv -f schedule_day2_tmp schedule_day2 + + git add * && git commit -m "Change poster sessions to talks" + + echo "" + echo "Your commits so far:" + echo "" + git log + + echo"" + echo "Your schedules:" + echo"" + ls +} + +init_advanced_repo () { + mkdir ../advanced_git + cd ../advanced_git + mkdir -p conference_planning + cd conference_planning + git init + cp ../../git-course/examples/schedule_day1 . + cp ../../git-course/examples/schedule_day2 . + + git add schedule_day1 && git commit -m "Add schedule_day1" + git add schedule_day2 && git commit -m "Add schedule_day2" + + ed -s schedule_day1 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null + ed -s schedule_day2 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null + git add * && git commit -m "Add poster sessions in the morning" + + ed -s schedule_day1 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null + ed -s schedule_day2 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null + git add * && git commit -m "Add coffee break" + git branch -m main + +} + +init_repo_remote () { + mkdir -p conference_planning + cd conference_planning + git init + cp ../../../examples/schedule_day1 . + + git add schedule_day1 && git commit -m "Add schedule_day1" + + ed -s schedule_day1 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null + git add * && git commit -m "Add poster sessions in the morning" + + ed -s schedule_day1 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null + git add * && git commit -m "Add coffee breaks" + + ed -s schedule_day1 <<< $'/break/\na\n11:15-12:15: Talk professor A.\n12:15-13:30: Lunch\n13:30-15:00: Workshop\n15:00-16:00: Talk professor B.\n.\nw\nq' > /dev/null + git add * && git commit -m "Add rest of daily program" + + cd .. + git clone conference_planning conference_planning_remote + cd conference_planning_remote + git switch -c "updated_schedules" + git switch main + + cd ../conference_planning + ls +} + +commit_to_remote_by_third_party() { + cd ../conference_planning_remote + git switch updated_schedules + sed 's/Poster session/Workshop/g' schedule_day1 > schedule_day1_tmp + mv -f schedule_day1_tmp schedule_day1 + git add * && git commit -m "Workshop in the morning" + git switch main + cd - +} diff --git a/advanced/Unix_Commands.ipynb b/beginner/Unix_Commands.ipynb similarity index 100% rename from advanced/Unix_Commands.ipynb rename to beginner/Unix_Commands.ipynb From de05cce61bec7d7e40077d96703c3364037366ec Mon Sep 17 00:00:00 2001 From: juckerj Date: Mon, 19 Sep 2022 12:18:20 +0200 Subject: [PATCH 08/23] fix ex. 3 --- advanced/examples/schedule_day1 | 7 +++++++ advanced/examples/schedule_day2 | 7 +++++++ advanced/helpers.sh | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 advanced/examples/schedule_day1 create mode 100644 advanced/examples/schedule_day2 diff --git a/advanced/examples/schedule_day1 b/advanced/examples/schedule_day1 new file mode 100644 index 0000000..739779a --- /dev/null +++ b/advanced/examples/schedule_day1 @@ -0,0 +1,7 @@ +*********** Schedule for Day 1 *************** +Daily program + + + +********** +Evening activity diff --git a/advanced/examples/schedule_day2 b/advanced/examples/schedule_day2 new file mode 100644 index 0000000..982b8ed --- /dev/null +++ b/advanced/examples/schedule_day2 @@ -0,0 +1,7 @@ +*********** Schedule for Day 2 *************** +Daily program + + + +********** +Evening activity diff --git a/advanced/helpers.sh b/advanced/helpers.sh index 40fcf6b..a00e9cc 100755 --- a/advanced/helpers.sh +++ b/advanced/helpers.sh @@ -124,8 +124,8 @@ init_advanced_repo () { mkdir -p conference_planning cd conference_planning git init - cp ../../git-course/examples/schedule_day1 . - cp ../../git-course/examples/schedule_day2 . + cp ../../advanced/examples/schedule_day1 . + cp ../../advanced/examples/schedule_day2 . git add schedule_day1 && git commit -m "Add schedule_day1" git add schedule_day2 && git commit -m "Add schedule_day2" From 35905541ef63f5740dbe4bf919c1d63bfb7ade9d Mon Sep 17 00:00:00 2001 From: juckerj <39263956+jonasjucker@users.noreply.github.com> Date: Mon, 19 Sep 2022 12:21:30 +0200 Subject: [PATCH 09/23] Update Exercise_5.md --- advanced/Exercise_5.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_5.md b/advanced/Exercise_5.md index 8467056..be746be 100644 --- a/advanced/Exercise_5.md +++ b/advanced/Exercise_5.md @@ -2,7 +2,7 @@ In this exercise, we will learn to use git rebase to rewrite the history of a feature branch in order to keep the history of the main branch cleaner by avoiding merge commits. First we will use the merge strategy to add a feature to a main branch that is being simultaneously developed. Then we will use the rebase strategy to do the same thing and compare the differences. -This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` section [here](./Exercise_3.md). +This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` [section of Exercise 3](./Exercise_3.md). * [Use the merge strategy to incorporate a change into a moving main branch](#merge) From f248110cace53405800bb360af63c30666947e3b Mon Sep 17 00:00:00 2001 From: juckerj <39263956+jonasjucker@users.noreply.github.com> Date: Mon, 19 Sep 2022 12:22:48 +0200 Subject: [PATCH 10/23] Update Exercise_6.md --- advanced/Exercise_6.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_6.md b/advanced/Exercise_6.md index 6b12fc6..ccf60e3 100644 --- a/advanced/Exercise_6.md +++ b/advanced/Exercise_6.md @@ -2,7 +2,7 @@ In this exercise, we will learn to use git to cherry pick a commit. We will add a series of commits to a feature branch, and then use cherry pick to apply only one of these commits to the main branch. -This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` section [here](./Exercise_3.md). +This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` [section of Exercise 3](./Exercise_3.md). * [Add feature branch and commits](#feature) From d974f6b5ceced93cbe696770195f7aedbde84140 Mon Sep 17 00:00:00 2001 From: juckerj <39263956+jonasjucker@users.noreply.github.com> Date: Mon, 19 Sep 2022 12:23:06 +0200 Subject: [PATCH 11/23] Update Exercise_7.md --- advanced/Exercise_7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_7.md b/advanced/Exercise_7.md index 4d4b326..fe0ce90 100644 --- a/advanced/Exercise_7.md +++ b/advanced/Exercise_7.md @@ -2,7 +2,7 @@ This exercise is designed to be paired with Exercise 7 to help you compare and contrast the two main methods for embedding a git repository into another git repository. This exercise illustrates the submodule method, while the next exercise illustrates the subtree method. In this exercise, we will learn to use git submodule to nest a git repository inside another one. We will first add the git submodule and examine how the host and nested repositories deal with changes in their respective files. We will then learn how to pull and push changes to and from the sub-repository. -This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` section [here](./Exercise_3.md). +This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` [section of Exercise 3](./Exercise_3.md). * [Fork a repository on Github and add it as a submodule](#submodule) From 89786ac667f4baf42f49d0e78d04cc7b985197be Mon Sep 17 00:00:00 2001 From: juckerj <39263956+jonasjucker@users.noreply.github.com> Date: Mon, 19 Sep 2022 12:24:04 +0200 Subject: [PATCH 12/23] Update Exercise_8.md --- advanced/Exercise_8.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_8.md b/advanced/Exercise_8.md index d6d6c1a..9ad2b56 100644 --- a/advanced/Exercise_8.md +++ b/advanced/Exercise_8.md @@ -2,7 +2,7 @@ This exercise is designed to be paired with Exercise 6 to help you compare and contrast the two main methods for embedding a git repository into another git repository. In this exercise, we will learn to use git subtree to nest a git repository inside another one. We will first add the git subtree and examine how the host and nested repositories deal with changes in their respective files. We will then learn how to pull and push changes to and from the sub-repository. -This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` section [here](./Exercise_3.md). +This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` [section of Exercise 3](./Exercise_3.md). * [Add the posters repository using git subtree](#subtree) From 2f8f8956f61af6a11603e5392f4ae5c2e3d09c02 Mon Sep 17 00:00:00 2001 From: juckerj Date: Mon, 19 Sep 2022 12:30:10 +0200 Subject: [PATCH 13/23] remove function only needed in advanced course --- advanced/helpers.sh | 155 -------------------------------------------- beginner/helpers.sh | 23 ------- 2 files changed, 178 deletions(-) diff --git a/advanced/helpers.sh b/advanced/helpers.sh index a00e9cc..7a17c41 100755 --- a/advanced/helpers.sh +++ b/advanced/helpers.sh @@ -1,123 +1,5 @@ #!/bin/bash -if [[ ! -z $dir_at_startup ]]; then - echo "You cannot source this file twice" -else - dir_at_startup=$(pwd) -fi - -reset () { - echo "Go back to $dir_at_startup" - cd $dir_at_startup - - echo "Restore clean working directory" - mkdir -p work - rm -rf work - mkdir work - cd work - - echo "Here we go again!" -} - -init_exercise () { - cd $dir_at_startup - mkdir -p work - cd work - echo "Working directory prepared" -} - -init_directory_with_empty_file () { - mkdir -p conference_planning - cd conference_planning - touch conference_schedule.txt -} - -init_simple_repo () { - mkdir -p conference_planning - cd conference_planning - git init - cp ../../../examples/schedule_day1 . - cp ../../../examples/schedule_day2 . - - git add schedule_day1 && git commit -m "Add schedule_day1" - git add schedule_day2 && git commit -m "Add schedule_day2" - - ed -s schedule_day1 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null - ed -s schedule_day2 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null - git add * && git commit -m "Add poster sessions in the morning" - - ed -s schedule_day1 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null - ed -s schedule_day2 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null - git add * && git commit -m "Add coffee break" - - echo "" - echo "Your commits so far:" - echo "" - git log - - echo"" - echo "Your schedules:" - echo"" - ls -} - -init_simple_repo_remote () { - mkdir -p conference_planning - cd conference_planning - git init - cp ../../../examples/schedule_day1 . - cp ../../../examples/schedule_day2 . - - git add schedule_day1 && git commit -m "Add schedule_day1" - git add schedule_day2 && git commit -m "Add schedule_day2" - - ed -s schedule_day1 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null - ed -s schedule_day2 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null - git add * && git commit -m "Add poster sessions in the morning" - - ed -s schedule_day1 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null - ed -s schedule_day2 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null - git add * && git commit -m "Add coffee breaks" - - cd .. - git clone conference_planning conference_planning_remote - cd conference_planning_remote - git switch -c "updated_schedules" - ed -s schedule_day1 <<< $'/break/\na\n11:15-12:15: Talk professor A.\n.\nw\nq' > /dev/null - ed -s schedule_day2 <<< $'/break/\na\n11:15-12:15: Talk professor B.\n.\nw\nq' > /dev/null - git add * && git commit -m "update schedules" - git switch main - - cd ../conference_planning - ls -} - -init_broken_repo () { - init_simple_repo &> /dev/null - - ed -s schedule_day1 <<< $'/break/\na\n11:15-12:15: Workshop ice crystal formation\n.\nw\nq' > /dev/null - ed -s schedule_day2 <<< $'/break/\na\n11:15-12:12: Workshop secondary ice\n.\nw\nq' > /dev/null - git add * && git commit -m "Add workshops" - - sed 's/Poster session/Talk professor C./g' schedule_day1 > schedule_day1_tmp - sed 's/Poster session/Talk professor D./g' schedule_day2 > schedule_day2_tmp - - mv -f schedule_day1_tmp schedule_day1 - mv -f schedule_day2_tmp schedule_day2 - - git add * && git commit -m "Change poster sessions to talks" - - echo "" - echo "Your commits so far:" - echo "" - git log - - echo"" - echo "Your schedules:" - echo"" - ls -} - init_advanced_repo () { mkdir ../advanced_git cd ../advanced_git @@ -140,40 +22,3 @@ init_advanced_repo () { git branch -m main } - -init_repo_remote () { - mkdir -p conference_planning - cd conference_planning - git init - cp ../../../examples/schedule_day1 . - - git add schedule_day1 && git commit -m "Add schedule_day1" - - ed -s schedule_day1 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null - git add * && git commit -m "Add poster sessions in the morning" - - ed -s schedule_day1 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null - git add * && git commit -m "Add coffee breaks" - - ed -s schedule_day1 <<< $'/break/\na\n11:15-12:15: Talk professor A.\n12:15-13:30: Lunch\n13:30-15:00: Workshop\n15:00-16:00: Talk professor B.\n.\nw\nq' > /dev/null - git add * && git commit -m "Add rest of daily program" - - cd .. - git clone conference_planning conference_planning_remote - cd conference_planning_remote - git switch -c "updated_schedules" - git switch main - - cd ../conference_planning - ls -} - -commit_to_remote_by_third_party() { - cd ../conference_planning_remote - git switch updated_schedules - sed 's/Poster session/Workshop/g' schedule_day1 > schedule_day1_tmp - mv -f schedule_day1_tmp schedule_day1 - git add * && git commit -m "Workshop in the morning" - git switch main - cd - -} diff --git a/beginner/helpers.sh b/beginner/helpers.sh index 40fcf6b..52b3f1c 100755 --- a/beginner/helpers.sh +++ b/beginner/helpers.sh @@ -118,29 +118,6 @@ init_broken_repo () { ls } -init_advanced_repo () { - mkdir ../advanced_git - cd ../advanced_git - mkdir -p conference_planning - cd conference_planning - git init - cp ../../git-course/examples/schedule_day1 . - cp ../../git-course/examples/schedule_day2 . - - git add schedule_day1 && git commit -m "Add schedule_day1" - git add schedule_day2 && git commit -m "Add schedule_day2" - - ed -s schedule_day1 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null - ed -s schedule_day2 <<< $'/program/\na\n09:00-11:00: Poster session\n.\nw\nq' > /dev/null - git add * && git commit -m "Add poster sessions in the morning" - - ed -s schedule_day1 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null - ed -s schedule_day2 <<< $'/session/\na\n11:00-11:15: Coffee break\n.\nw\nq' > /dev/null - git add * && git commit -m "Add coffee break" - git branch -m main - -} - init_repo_remote () { mkdir -p conference_planning cd conference_planning From 32dde9bdb75d999f19b1800a8e5940b59f3ecd33 Mon Sep 17 00:00:00 2001 From: juckerj <39263956+jonasjucker@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:24:40 +0200 Subject: [PATCH 14/23] Update README.md --- README.md | 49 +++++-------------------------------------------- 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 1f6d7c7..a577f98 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,8 @@ -# Git Course for Beginners -This repository contains the exercises for the C2SM Git Workshop "Git for Beginners". -Feel free to download the material to practice and enhance your Git skills. +# C2SM Git Courses -The corresponding [slides of this course](https://wiki.c2sm.ethz.ch/CM/WorkshopBestPractices2013) can be found -at the C2SM wiki. +## Git Course for Beginners +The folder [beginner](beginner) contains the exercises for the C2SM Git Workshop "Git for Beginners". -A Markdown version of the .ipynb files for each exercise is located in the [Markdowns folder](Markdowns). -We recommend to make use of the convienient way of doing the exercises with Jupyter Notebook itself. -For installation instructions see section below. - -## How to run the exercises -First of all, you need a Git installation on your computer. -To do so, please follow the [instructions from GitHub](https://github.com/git-guides/install-git). - -> **_Important note:_** You must have at least Git 2.28 (released 27 July 2020) installed. -> You can check your Git version by typing `git --version` in your terminal. - -Second, you need a Python installation as well. -We provide you here with [instructions from realpython](https://realpython.com/installing-python/), -but of course many other instruction will do it as well. - -Third, you need some non-standard python packages, namely: - - jupyterlab - - bash_kernel - -To install these two packages, execute the following command in your terminal: -``` -python -m venv git-course_env -source git-course_env/bin/activate -pip install -r requirements.txt -``` -On some machines an additional step is necessary: -``` -python -m bash_kernel.install -``` - -Finally, you can start with the exercises by running: -``` -jupyter notebook -``` -This command opens the Jupyter Notebook interface in your browser. -If it does not open automatically, you have to copy and paste the URL manually. -In that case, please follow the instructions in your terminal. - -**Have fun!** +## Git Course for Advanced +The folder [advanced](advanced) contains the exercises for the C2SM Git Workshop "Git for Advanced" From a8f9b7b0e0c41344c4168ef7ea9686d0b0da3352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20J=C3=A4hn?= Date: Tue, 20 Sep 2022 08:56:26 +0200 Subject: [PATCH 15/23] Update Exercise_3.md --- advanced/Exercise_3.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_3.md b/advanced/Exercise_3.md index bec3158..23ec027 100644 --- a/advanced/Exercise_3.md +++ b/advanced/Exercise_3.md @@ -1,6 +1,6 @@ # Exercise 3 - Ignoring files -In this exercise, you will first use a provided script to generate a simple git repository containing materials for planning a conference. You will then create a README file for the conference planning repository using the Markdown language. Then you will generate an HTML README file, and finally create a `.gitignore` file for the repository. This exercise is closely adapted from [OESA Git Workshop](https://oesa.pages.ufz.de/git-exercises/exercise-5.html). +In this exercise, you will first use a provided script to generate a simple git repository containing materials for planning a conference. You will then create a README file for the conference planning repository using the Markdown language. Then you will generate an HTML README file, and finally create a `.gitignore` file for the repository. This exercise is closely adapted from the [OESA Git Workshop](https://oesa.pages.ufz.de/git-exercises/exercise-5.html). * [Initialize the git repository](#initialize) From 103aed97ed66e00bda9f584f9c5787b39ad3dc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20J=C3=A4hn?= Date: Tue, 20 Sep 2022 08:58:03 +0200 Subject: [PATCH 16/23] Update Exercise_5.md --- advanced/Exercise_5.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_5.md b/advanced/Exercise_5.md index be746be..0d9a935 100644 --- a/advanced/Exercise_5.md +++ b/advanced/Exercise_5.md @@ -2,7 +2,7 @@ In this exercise, we will learn to use git rebase to rewrite the history of a feature branch in order to keep the history of the main branch cleaner by avoiding merge commits. First we will use the merge strategy to add a feature to a main branch that is being simultaneously developed. Then we will use the rebase strategy to do the same thing and compare the differences. -This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` [section of Exercise 3](./Exercise_3.md). +This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the ["Initialize the git repository" section of Exercise 3](./Exercise_3.md#initialize). * [Use the merge strategy to incorporate a change into a moving main branch](#merge) From 554894448c91b358ca2941df26dd68da27048f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20J=C3=A4hn?= Date: Tue, 20 Sep 2022 09:10:26 +0200 Subject: [PATCH 17/23] Update Exercises --- advanced/Exercise_5.md | 4 ++-- advanced/Exercise_6.md | 2 +- advanced/Exercise_7.md | 4 ++-- advanced/Exercise_8.md | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/advanced/Exercise_5.md b/advanced/Exercise_5.md index 0d9a935..2ac58e2 100644 --- a/advanced/Exercise_5.md +++ b/advanced/Exercise_5.md @@ -1,6 +1,6 @@ # Exercise 5 - Using git rebase -In this exercise, we will learn to use git rebase to rewrite the history of a feature branch in order to keep the history of the main branch cleaner by avoiding merge commits. First we will use the merge strategy to add a feature to a main branch that is being simultaneously developed. Then we will use the rebase strategy to do the same thing and compare the differences. +In this exercise, we will learn to use `git rebase` to rewrite the history of a feature branch in order to keep the history of the main branch cleaner by avoiding merge commits. First we will use the merge strategy to add a feature to a main branch that is being simultaneously developed. Then we will use the rebase strategy to do the same thing and compare the differences. This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the ["Initialize the git repository" section of Exercise 3](./Exercise_3.md#initialize). @@ -18,7 +18,7 @@ Create and switch to a new feature branch. git switch -c merge_feature ``` -Make a change to the schedule for day 2. Let's add a presentation session. The following gives examples using the `sed` command line tool, which were tested on Linux but may not work on other platforms. You can also simply open the file in a file editor to make the change. +Make a change to the schedule for day 2. Let's add a presentation session. The following are examples of how to use the `sed` command line tool, which were tested on Linux but may not work on other platforms. You can also simply open the file in a file editor to make the change. ```plaintext sed -i '/Coffee/ a 11:15-12:30: Presentation session' schedule_day2 diff --git a/advanced/Exercise_6.md b/advanced/Exercise_6.md index ccf60e3..a6a7e1e 100644 --- a/advanced/Exercise_6.md +++ b/advanced/Exercise_6.md @@ -2,7 +2,7 @@ In this exercise, we will learn to use git to cherry pick a commit. We will add a series of commits to a feature branch, and then use cherry pick to apply only one of these commits to the main branch. -This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` [section of Exercise 3](./Exercise_3.md). +This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the ["Initialize the git repository" section of Exercise 3](./Exercise_3.md#initialize). * [Add feature branch and commits](#feature) diff --git a/advanced/Exercise_7.md b/advanced/Exercise_7.md index fe0ce90..c999e5f 100644 --- a/advanced/Exercise_7.md +++ b/advanced/Exercise_7.md @@ -2,7 +2,7 @@ This exercise is designed to be paired with Exercise 7 to help you compare and contrast the two main methods for embedding a git repository into another git repository. This exercise illustrates the submodule method, while the next exercise illustrates the subtree method. In this exercise, we will learn to use git submodule to nest a git repository inside another one. We will first add the git submodule and examine how the host and nested repositories deal with changes in their respective files. We will then learn how to pull and push changes to and from the sub-repository. -This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` [section of Exercise 3](./Exercise_3.md). +This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the ["Initialize the git repository" section of Exercise 3](./Exercise_3.md#initialize). * [Fork a repository on Github and add it as a submodule](#submodule) @@ -45,7 +45,7 @@ The output shows that there are some changes to the repository, and they are alr git commit -m "Add the posters submodule" ``` -Note that the .gitmodules file has been added, which contains the path of the submodule in the host repository and the address where the submodule is hosted which is the Github URL in our case. It could also be another git web host, a file path, or anywhere else a repository is hosted. +Note that the `.gitmodules` file has been added, which contains the path of the submodule in the host repository and the address where the submodule is hosted which is the Github URL in our case. It could also be another git web host, a file path, or anywhere else a repository is hosted. Check the status of the submodule. diff --git a/advanced/Exercise_8.md b/advanced/Exercise_8.md index 9ad2b56..c729c4e 100644 --- a/advanced/Exercise_8.md +++ b/advanced/Exercise_8.md @@ -1,8 +1,8 @@ # Exercise 8 - Using git subtree -This exercise is designed to be paired with Exercise 6 to help you compare and contrast the two main methods for embedding a git repository into another git repository. In this exercise, we will learn to use git subtree to nest a git repository inside another one. We will first add the git subtree and examine how the host and nested repositories deal with changes in their respective files. We will then learn how to pull and push changes to and from the sub-repository. +This exercise is designed to be paired with Exercise 6 to help you compare and contrast the two main methods for embedding a git repository into another git repository. In this exercise, we will learn to use `git subtree` to nest a git repository inside another one. We will first add the git subtree and examine how the host and nested repositories deal with changes in their respective files. We will then learn how to pull and push changes to and from the sub-repository. -This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the `Initialize the git repository` [section of Exercise 3](./Exercise_3.md). +This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the ["Initialize the git repository" section of Exercise 3](./Exercise_3.md#initialize). * [Add the posters repository using git subtree](#subtree) @@ -69,7 +69,7 @@ cd posters git status ``` -Here we see the same change listed as not staged for commit. This is a difference to the behavior we saw with submodules. With git subtrees, git considers both the host and nested repository to have the same staging area. The commits from the subtree are all put directly into the commit list of the host repository, unlike with git submodule where they are kept completely separate. +Here we see the same change listed as not staged for commit. This is a difference to the behavior we saw with submodules. With git subtrees, git considers both the host and nested repository to have the same staging area. The commits from the subtree are all put directly into the commit list of the host repository, unlike with `git submodule` where they are kept completely separate. Now try making a change inside the submodule. Let's add another poster title to the poster schedule. From bb961cfb4f453b0c3f30d17ef7908768d53a7e47 Mon Sep 17 00:00:00 2001 From: Annika Date: Tue, 20 Sep 2022 09:18:27 +0200 Subject: [PATCH 18/23] typo --- advanced/Exercise_7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_7.md b/advanced/Exercise_7.md index c999e5f..42f9648 100644 --- a/advanced/Exercise_7.md +++ b/advanced/Exercise_7.md @@ -1,6 +1,6 @@ # Exercise 7 - Using git submodule -This exercise is designed to be paired with Exercise 7 to help you compare and contrast the two main methods for embedding a git repository into another git repository. This exercise illustrates the submodule method, while the next exercise illustrates the subtree method. In this exercise, we will learn to use git submodule to nest a git repository inside another one. We will first add the git submodule and examine how the host and nested repositories deal with changes in their respective files. We will then learn how to pull and push changes to and from the sub-repository. +This exercise is designed to be paired with Exercise 8 to help you compare and contrast the two main methods for embedding a git repository into another git repository. This exercise illustrates the submodule method, while the next exercise illustrates the subtree method. In this exercise, we will learn to use git submodule to nest a git repository inside another one. We will first add the git submodule and examine how the host and nested repositories deal with changes in their respective files. We will then learn how to pull and push changes to and from the sub-repository. This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the ["Initialize the git repository" section of Exercise 3](./Exercise_3.md#initialize). From 9dd9bf9e7cca2c5c016e03786c78ad438cad3246 Mon Sep 17 00:00:00 2001 From: Annika Date: Tue, 20 Sep 2022 09:18:50 +0200 Subject: [PATCH 19/23] typo --- advanced/Exercise_8.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_8.md b/advanced/Exercise_8.md index c729c4e..f8a8794 100644 --- a/advanced/Exercise_8.md +++ b/advanced/Exercise_8.md @@ -1,6 +1,6 @@ # Exercise 8 - Using git subtree -This exercise is designed to be paired with Exercise 6 to help you compare and contrast the two main methods for embedding a git repository into another git repository. In this exercise, we will learn to use `git subtree` to nest a git repository inside another one. We will first add the git subtree and examine how the host and nested repositories deal with changes in their respective files. We will then learn how to pull and push changes to and from the sub-repository. +This exercise is designed to be paired with Exercise 7 to help you compare and contrast the two main methods for embedding a git repository into another git repository. In this exercise, we will learn to use `git subtree` to nest a git repository inside another one. We will first add the git subtree and examine how the host and nested repositories deal with changes in their respective files. We will then learn how to pull and push changes to and from the sub-repository. This exercise uses the same git repository that was created in Exercise 3. If you have not already done so, you can create it by following the instructions in the ["Initialize the git repository" section of Exercise 3](./Exercise_3.md#initialize). From ab5196614da2d183805f2a4134f0de4de7dd8c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20J=C3=A4hn?= Date: Tue, 20 Sep 2022 09:20:50 +0200 Subject: [PATCH 20/23] Change master to main --- advanced/Exercise_4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_4.md b/advanced/Exercise_4.md index 1d07594..c720dd0 100644 --- a/advanced/Exercise_4.md +++ b/advanced/Exercise_4.md @@ -79,4 +79,4 @@ Let's suppose that in addition to working in the main branch of the repository, git worktree add feature ``` -Because the branch `feature` did not already exist, one has been created from the master branch. It is now located in the `feature` folder, and you can now navigate there and work as you normally would in your git working directory. Note that you can also push and fetch commits as you normally would to and from remote repositories if you need to. +Because the branch `feature` did not already exist, one has been created from the main branch. It is now located in the `feature` folder, and you can now navigate there and work as you normally would in your git working directory. Note that you can also push and fetch commits as you normally would to and from remote repositories if you need to. From 7d2307b291bff883067afdaa5992b8c775b9b9dd Mon Sep 17 00:00:00 2001 From: Annika Date: Tue, 20 Sep 2022 09:24:40 +0200 Subject: [PATCH 21/23] add command for "sed -i" not working on Mac --- advanced/Exercise_4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_4.md b/advanced/Exercise_4.md index c720dd0..e55f9db 100644 --- a/advanced/Exercise_4.md +++ b/advanced/Exercise_4.md @@ -10,7 +10,7 @@ This exercise uses the same git repository that was created in Exercise 3. If yo ## Stash your changes -Let's make a change to the repository by adding a conference breakfast to the schedule on day 1. +Let's make a change to the repository by adding a conference breakfast to the schedule on day 1. The following are examples of how to use the `sed` command line tool, which were tested on Linux but may not work on other platforms. You can also simply open the file in a file editor to make the change. ```plaintext sed -i '/Daily/ a 08:30-09:00: Conference breakfast' schedule_day1 From cf0b71b760fee4655f7aab4e6368b2e957879b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20J=C3=A4hn?= Date: Tue, 20 Sep 2022 09:44:29 +0200 Subject: [PATCH 22/23] Reference correct exercise --- advanced/Exercise_8.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Exercise_8.md b/advanced/Exercise_8.md index f8a8794..619e234 100644 --- a/advanced/Exercise_8.md +++ b/advanced/Exercise_8.md @@ -20,7 +20,7 @@ Navigate to the folder containing the `conference_planning` folder; in other wor cp -r conference_planning conference_subtree ``` -Let's add your `posters` Github fork we created in Exercise 6 as a subtree to our conference planning repository. +Let's add your `posters` Github fork we created in Exercise 7 as a subtree to our conference planning repository. ```plaintext cd conference_subtree From 5134a11a53c3a57b68be9f3233f12af2844c9f99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20J=C3=A4hn?= Date: Tue, 20 Sep 2022 10:02:56 +0200 Subject: [PATCH 23/23] Add note for working tree error --- advanced/Exercise_8.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/advanced/Exercise_8.md b/advanced/Exercise_8.md index 619e234..603adac 100644 --- a/advanced/Exercise_8.md +++ b/advanced/Exercise_8.md @@ -27,6 +27,8 @@ cd conference_subtree git subtree add --prefix posters YOUR_FORK_ADDRESS main --squash ``` +> **_Note:_** If you get an error message of the type `Working tree has modifications. Cannot add.`, please first try `git switch main`. If the error still persists, type `git reset --hard`. For more information about this, check [this stackoverflow question](https://stackoverflow.com/questions/3623351/git-subtree-pull-says-that-the-working-tree-has-modifications-but-git-status-sa). + The `--prefix` option gives a folder name relative to the root of the parent repository where the subtree will be installed. And the `--squash` option squashes the history of the posters repository into one commit in the parent repository. Check the status of the repository.