From 231fb970c27542f68b4a1a610c86ec2f7159b1e0 Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Thu, 13 Jul 2023 20:17:44 +0100 Subject: [PATCH 01/13] =?UTF-8?q?=F0=9F=A5=91-ise=20the=20lesson:=20from?= =?UTF-8?q?=20planets=20to=20recipes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migrated old changes made to the styles lesson but as sandpaper This includes the changes done to: 5c3f2974f2f046711c3d7a338c1b8c985d8bdd1d ca6d8333d96184bf15877a44304553a795127e12 376bc11d3320006b3b816fca838ad627e0f55875 --- README.md | 14 +- episodes/02-setup.md | 14 +- episodes/03-create.md | 75 +++--- episodes/04-changes.md | 238 +++++++++-------- episodes/05-history.md | 215 +++++++-------- episodes/06-ignore.md | 96 +++---- episodes/07-github.md | 77 +++--- episodes/08-collab.md | 44 ++-- episodes/09-conflict.md | 244 +++++++++++------- episodes/14-supplemental-rstudio.md | 6 +- episodes/fig/git-freshly-made-github-repo.svg | 4 +- episodes/fig/github-collaboration.svg | 10 +- episodes/fig/github-repo-after-first-push.svg | 6 +- index.md | 8 +- instructors/instructor-notes.md | 8 +- learners/discuss.md | 130 +++++----- 16 files changed, 636 insertions(+), 553 deletions(-) diff --git a/README.md b/README.md index 3ab5c26d25..20ebefac60 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,17 @@ [![Create a Slack Account with us](https://img.shields.io/badge/Create_Slack_Account-The_Carpentries-071159.svg)](https://swc-slack-invite.herokuapp.com/) [![Slack Status](https://img.shields.io/badge/Slack_Channel-swc--git-E01563.svg)](https://swcarpentry.slack.com/messages/C91JS49HD) -# git-novice +# # UCL's git-novice -An introduction to version control for novices using Git. -Please see [https://swcarpentry.github.io/git-novice/](https://swcarpentry.github.io/git-novice/) for a rendered version of this material, +An introduction to version control for novices using Git (with the UCL's twist). +Please see [the rendered version of this material](https://github-pages.ucl.ac.uk/git-novice/), [the lesson template documentation][lesson-example] for instructions on formatting, building, and submitting material, or run `make` in this directory for a list of helpful commands. -Maintainers: +## Maintainers: + +## Upstream - [Nima Hejazi][hejazi_nima]: [@nhejazi](https://github.com/nhejazi) - [Kat Koziar][koziar_kat]: [@kekoziar](https://github.com/kekoziar) @@ -20,6 +22,10 @@ Alumni maintainers: - [Ivan Gonzalez][gonzalez_ivan]: [@iglpdc](https://github.com/iglpdc) - [Daisie Huang][huang_daisie]: [@daisieh](https://github.com/daisieh) +## UCL's + +- David Pérez-Suárez [@dpshelio](https://github.com/dpshelio) + [lesson-example]: https://swcarpentry.github.io/lesson-example [hejazi_nima]: https://carpentries.org/instructors/#nhejazi [koziar_kat]: https://carpentries.org/instructors/#kekoziar diff --git a/episodes/02-setup.md b/episodes/02-setup.md index 167534a968..e1d7584885 100644 --- a/episodes/02-setup.md +++ b/episodes/02-setup.md @@ -27,14 +27,14 @@ of configurations we will set as we get started with Git: On a command line, Git commands are written as `git verb options`, where `verb` is what we actually want to do and `options` is additional optional information which may be needed for the `verb`. So here is how -Dracula sets up his new laptop: +Alfredo sets up his new laptop: ```bash -$ git config --global user.name "Vlad Dracula" -$ git config --global user.email "vlad@tran.sylvan.ia" +$ git config --global user.name "Alfredo Linguini" +$ git config --global user.email "a.linguini@ratatouille.fr" ``` -Please use your own name and email address instead of Dracula's. This user name and email will be associated with your subsequent Git activity, +Please use your own name and email address instead of Alfredo's. This user name and email will be associated with your subsequent Git activity, which means that any changes pushed to [GitHub](https://github.com/), [BitBucket](https://bitbucket.org/), @@ -79,12 +79,12 @@ $ git config --global core.autocrlf input And on Windows: ```bash -$ git config --global core.autocrlf false +$ git config --global core.autocrlf true ``` :::::::::::::::::::::::::::::::::::::::::::::::::: -Dracula also has to set his favorite text editor, following this table: +Alfredo also has to set his favorite text editor, following this table: | Editor | Configuration command | | :----------- | :------------------------------ | @@ -118,7 +118,7 @@ If you want to save your changes and quit, press Esc then type `:wq` :::::::::::::::::::::::::::::::::::::::::::::::::: Git (2.28+) allows configuration of the name of the branch created when you -initialize any new repository. Dracula decides to use that feature to set it to `main` so +initialize any new repository. Alfredo decides to use that feature to set it to `main` so it matches the cloud service he will eventually use. ```bash diff --git a/episodes/03-create.md b/episodes/03-create.md index 35e1ee402f..5d706facd7 100644 --- a/episodes/03-create.md +++ b/episodes/03-create.md @@ -20,32 +20,17 @@ exercises: 0 Once Git is configured, we can start using it. -We will continue with the story of Wolfman and Dracula who are investigating if it -is possible to send a planetary lander to Mars. - -![](fig/motivatingexample.png){alt='motivatingexample'} -[Werewolf vs dracula](https://www.deviantart.com/b-maze/art/Werewolf-vs-Dracula-124893530) -by [b-maze](https://www.deviantart.com/b-maze) / [Deviant Art](https://www.deviantart.com/). -[Mars](https://en.wikipedia.org/wiki/File:OSIRIS_Mars_true_color.jpg) by European Space Agency / -[CC-BY-SA 3.0 IGO](https://creativecommons.org/licenses/by/3.0/deed.en). -[Pluto](https://commons.wikimedia.org/wiki/File:PIA19873-Pluto-NewHorizons-FlyingPastImage-20150714-transparent.png) / -Courtesy NASA/JPL-Caltech. -[Mummy](https://commons.wikimedia.org/wiki/File:Mummy_icon_-_Noun_Project_4070.svg) -© Gilad Fried / [The Noun Project](https://thenounproject.com/) / -[CC BY 3.0](https://creativecommons.org/licenses/by/3.0/deed.en). -[Moon](https://commons.wikimedia.org/wiki/File:Lune_ico.png) -© Luc Viatour / [https://lucnix.be](https://lucnix.be/) / -[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/deed.en). +We will help Alfredo with his new project, create a repository with all his recipes. First, let's create a new directory in the `Desktop` folder for our work and then change the current working directory to the newly created one: ```bash $ cd ~/Desktop -$ mkdir planets -$ cd planets +$ mkdir recipes +$ cd recipes ``` -Then we tell Git to make `planets` a [repository](../learners/reference.md#repository) +Then we tell Git to make `recipes` a [repository](../learners/reference.md#repository) \-- a place where Git can store versions of our files: ```bash @@ -54,9 +39,9 @@ $ git init It is important to note that `git init` will create a repository that can include subdirectories and their files---there is no need to create -separate repositories nested within the `planets` repository, whether +separate repositories nested within the `recipes` repository, whether subdirectories are present from the beginning or added later. Also, note -that the creation of the `planets` directory and its initialization as a +that the creation of the `recipes` directory and its initialization as a repository are completely separate processes. If we use `ls` to show the directory's contents, @@ -67,7 +52,7 @@ $ ls ``` But if we add the `-a` flag to show everything, -we can see that Git has created a hidden directory within `planets` called `.git`: +we can see that Git has created a hidden directory within `recipes` called `.git`: ```bash $ ls -a @@ -117,33 +102,33 @@ wording of the output might be slightly different. ## Places to Create Git Repositories -Along with tracking information about planets (the project we have already created), -Dracula would also like to track information about moons. -Despite Wolfman's concerns, Dracula creates a `moons` project inside his `planets` +Along with tracking information about recipes (the project we have already created), +Alfredo would also like to track information about cocktails. +Despite Jimmy's concerns, Alfredo creates a `cocktails` project inside his `recipes` project with the following sequence of commands: ```bash -$ cd ~/Desktop # return to Desktop directory -$ cd planets # go into planets directory, which is already a Git repository -$ ls -a # ensure the .git subdirectory is still present in the planets directory -$ mkdir moons # make a subdirectory planets/moons -$ cd moons # go into moons subdirectory -$ git init # make the moons subdirectory a Git repository -$ ls -a # ensure the .git subdirectory is present indicating we have created a new Git repository +$ cd ~/Desktop # return to Desktop directory +$ cd recipes # go into recipes directory, which is already a Git repository +$ ls -a # ensure the .git subdirectory is still present in the recipes directory +$ mkdir cocktails # make a sub-directory recipes/cocktails +$ cd cocktails # go into cocktails subdirectory +$ git init # make the cocktails subdirectory a Git repository +$ ls -a # ensure the .git subdirectory is present indicating we have created a new Git repository ``` -Is the `git init` command, run inside the `moons` subdirectory, required for -tracking files stored in the `moons` subdirectory? +Is the `git init` command, run inside the `cocktails` subdirectory, required for +tracking files stored in the `cocktails` subdirectory? ::::::::::::::: solution ## Solution -No. Dracula does not need to make the `moons` subdirectory a Git repository -because the `planets` repository can track any files, sub-directories, and -subdirectory files under the `planets` directory. Thus, in order to track -all information about moons, Dracula only needed to add the `moons` subdirectory -to the `planets` directory. +No. Alfredo does not need to make the `cocktails` subdirectory a Git repository +because the `recipes` repository will track all files, sub-directories, and +subdirectory files under the `recipes` directory. Thus, in order to track +all information about cocktails, Alfredo only needed to add the `cocktails` subdirectory +to the `recipes` directory. Additionally, Git repositories can interfere with each other if they are "nested": the outer repository will try to version-control @@ -165,9 +150,9 @@ fatal: Not a git repository (or any of the parent directories): .git ## Correcting `git init` Mistakes -Wolfman explains to Dracula how a nested repository is redundant and may cause confusion -down the road. Dracula would like to remove the nested repository. How can Dracula undo -his last `git init` in the `moons` subdirectory? +Jimmy explains to Alfredo how a nested repository is redundant and may cause confusion +down the road. Alfredo would like to remove the nested repository. How can Alfredo undo +his last `git init` in the `cocktails` subdirectory? ::::::::::::::: solution @@ -190,11 +175,11 @@ becomes another change that we will need to track, as we will see in the next ep ### Solution Git keeps all of its files in the `.git` directory. -To recover from this little mistake, Dracula can just remove the `.git` -folder in the moons subdirectory by running the following command from inside the `planets` directory: +To recover from this little mistake, Alfredo can just remove the `.git` +folder in the cocktails subdirectory by running the following command from inside the `recipes` directory: ```bash -$ rm -rf moons/.git +$ rm -rf cocktails/.git ``` But be careful! Running this command in the wrong directory will remove diff --git a/episodes/04-changes.md b/episodes/04-changes.md index 82c5689faa..d3f27ca30d 100644 --- a/episodes/04-changes.md +++ b/episodes/04-changes.md @@ -21,26 +21,27 @@ exercises: 0 :::::::::::::::::::::::::::::::::::::::::::::::::: First let's make sure we're still in the right directory. -You should be in the `planets` directory. +You should be in the `recipes` directory. ```bash -$ cd ~/Desktop/planets +$ cd ~/Desktop/recipes ``` -Let's create a file called `mars.txt` that contains some notes -about the Red Planet's suitability as a base. +Let's create a file called `guacamole.md` that contains the basic structure to +have a recipe. We'll use `nano` to edit the file; you can use whatever editor you like. In particular, this does not have to be the `core.editor` you set globally earlier. But remember, the bash command to create or edit a new file will depend on the editor you choose (it might not be `nano`). For a refresher on text editors, check out ["Which Editor?"](https://swcarpentry.github.io/shell-novice/03-create.html#which-editor) in [The Unix Shell](https://swcarpentry.github.io/shell-novice/) lesson. ```bash -$ nano mars.txt +$ nano guacamole.md ``` -Type the text below into the `mars.txt` file: +Type the text below into the `guacamole.md` file: ```output -Cold and dry, but everything is my favorite color +# Ingredients +# Instructions ``` Let's first verify that the file was properly created by running the list command (`ls`): @@ -50,17 +51,18 @@ $ ls ``` ```output -mars.txt +guacamole.md ``` -`mars.txt` contains a single line, which we can see by running: +`guacamole.md` contains a single line, which we can see by running: ```bash -$ cat mars.txt +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color +# Ingredients +# Instructions ``` If we check the status of our project again, @@ -78,7 +80,7 @@ No commits yet Untracked files: (use "git add ..." to include in what will be committed) - mars.txt + guacamole.md nothing added to commit but untracked files present (use "git add" to track) ``` @@ -88,7 +90,7 @@ that Git isn't keeping track of. We can tell Git to track a file using `git add`: ```bash -$ git add mars.txt +$ git add guacamole.md ``` and then check that the right thing happened: @@ -105,23 +107,23 @@ No commits yet Changes to be committed: (use "git rm --cached ..." to unstage) - new file: mars.txt + new file: guacamole.md ``` -Git now knows that it's supposed to keep track of `mars.txt`, +Git now knows that it's supposed to keep track of `guacamole.md`, but it hasn't recorded these changes as a commit yet. To get it to do that, we need to run one more command: ```bash -$ git commit -m "Start notes on Mars as a base" +$ git commit -m "Create a template for recipe" ``` ```output -[main (root-commit) f22b25e] Start notes on Mars as a base +[main (root-commit) f22b25e] Create a template for recipe 1 file changed, 1 insertion(+) - create mode 100644 mars.txt + create mode 100644 guacamole.md ``` When we run `git commit`, @@ -161,10 +163,10 @@ $ git log ```output commit f22b25e3233b4645dabd0d81e651fe074bd8e73b -Author: Vlad Dracula +Author: Alfredo Linguini Date: Thu Aug 22 09:51:46 2013 -0400 - Start notes on Mars as a base + Create a template for recipe ``` `git log` lists all commits made to a repository in reverse chronological order. @@ -180,7 +182,7 @@ and the log message Git was given when the commit was created. ## Where Are My Changes? -If we run `ls` at this point, we will still see just one file called `mars.txt`. +If we run `ls` at this point, we will still see just one file called `guacamole.md`. That's because Git saves information about files' history in the special `.git` directory mentioned earlier so that our filesystem doesn't become cluttered @@ -189,18 +191,21 @@ so that our filesystem doesn't become cluttered :::::::::::::::::::::::::::::::::::::::::::::::::: -Now suppose Dracula adds more information to the file. +Now suppose Alfredo adds more information to the file. (Again, we'll edit with `nano` and then `cat` the file to show its contents; you may use a different editor, and don't need to `cat`.) ```bash -$ nano mars.txt -$ cat mars.txt +$ nano guacamole.md +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color -The two moons may be a problem for Wolfman +# Ingredients +- avocado +- lemon +- salt +# Instructions ``` When we run `git status` now, @@ -216,7 +221,7 @@ Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) - modified: mars.txt + modified: guacamole.md no changes added to commit (use "git add" and/or "git commit -a") ``` @@ -237,13 +242,16 @@ $ git diff ``` ```output -diff --git a/mars.txt b/mars.txt +diff --git a/guacamole.md b/guacamole.md index df0654a..315bf3a 100644 ---- a/mars.txt -+++ b/mars.txt -@@ -1 +1,2 @@ - Cold and dry, but everything is my favorite color -+The two moons may be a problem for Wolfman +--- a/guacamole.md ++++ b/guacamole.md +@@ -1,2 +1,5 @@ + # Ingredients ++- avocado ++- lemon ++- salt + # Instructions ``` The output is cryptic because @@ -265,7 +273,8 @@ If we break it down into pieces: After reviewing our change, it's time to commit it: ```bash -$ git commit -m "Add concerns about effects of Mars' moons on Wolfman" +$ git commit -m "Add basic guacamole's ingredients" +$ git status ``` ```output @@ -274,7 +283,7 @@ Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) - modified: mars.txt + modified: guacamole.md no changes added to commit (use "git add" and/or "git commit -a") ``` @@ -284,13 +293,13 @@ Git won't commit because we didn't use `git add` first. Let's fix that: ```bash -$ git add mars.txt -$ git commit -m "Add concerns about effects of Mars' moons on Wolfman" +$ git add guacamole.md +$ git commit -m "Add basic guacamole's ingredients" ``` ```output -[main 34961b1] Add concerns about effects of Mars' moons on Wolfman - 1 file changed, 1 insertion(+) +[main 34961b1] Add basic guacamole's ingredient + 1 file changed, 3 insertions(+) ``` Git insists that we add files to the set we want to commit @@ -340,17 +349,19 @@ Let's watch as our changes to a file move from our editor to the staging area and into long-term storage. First, -we'll add another line to the file: +we'll improve our recipe by changing 'lemon' to 'lime': ```bash -$ nano mars.txt -$ cat mars.txt +$ nano guacamole.md +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color -The two moons may be a problem for Wolfman -But the Mummy will appreciate the lack of humidity +# Ingredients +- avocado +- lime +- salt +# Instructions ``` ```bash @@ -358,24 +369,27 @@ $ git diff ``` ```output -diff --git a/mars.txt b/mars.txt +diff --git a/guacamole.md b/guacamole.md index 315bf3a..b36abfd 100644 ---- a/mars.txt -+++ b/mars.txt -@@ -1,2 +1,3 @@ - Cold and dry, but everything is my favorite color - The two moons may be a problem for Wolfman -+But the Mummy will appreciate the lack of humidity +--- a/guacamole.md ++++ b/guacamole.md +@@ -1,5 +1,5 @@ + # Ingredients + - avocado +-- lemon ++- lime + - salt + # Instructions ``` So far, so good: -we've added one line to the end of the file +we've replaced one line (shown with a `-` in the first column) with a new line (shown with a `+` in the first column). Now let's put that change in the staging area and see what `git diff` reports: ```bash -$ git add mars.txt +$ git add guacamole.md $ git diff ``` @@ -391,14 +405,17 @@ $ git diff --staged ``` ```output -diff --git a/mars.txt b/mars.txt +diff --git a/guacamole.md b/guacamole.md index 315bf3a..b36abfd 100644 ---- a/mars.txt -+++ b/mars.txt -@@ -1,2 +1,3 @@ - Cold and dry, but everything is my favorite color - The two moons may be a problem for Wolfman -+But the Mummy will appreciate the lack of humidity +--- a/guacamole.md ++++ b/guacamole.md +@@ -1,5 +1,5 @@ + # Ingredients + - avocado +-- lemon ++- lime + - salt + # Instructions ``` it shows us the difference between @@ -407,11 +424,11 @@ and what's in the staging area. Let's save our changes: ```bash -$ git commit -m "Discuss concerns about Mars' climate for Mummy" +$ git commit -m "Modify guacamole to the traditional recipe" ``` ```output -[main 005937f] Discuss concerns about Mars' climate for Mummy +[main 005937f] Modify guacamole to the traditional recipe 1 file changed, 1 insertion(+) ``` @@ -434,22 +451,22 @@ $ git log ```output commit 005937fbe2a98fb83f0ade869025dc2636b4dad5 (HEAD -> main) -Author: Vlad Dracula +Author: Alfredo Linguini Date: Thu Aug 22 10:14:07 2013 -0400 - Discuss concerns about Mars' climate for Mummy + Modify guacamole to the traditional recipe commit 34961b159c27df3b475cfe4415d94a6d1fcd064d -Author: Vlad Dracula +Author: Alfredo Linguini Date: Thu Aug 22 10:07:21 2013 -0400 - Add concerns about effects of Mars' moons on Wolfman + Add basic guacamole's ingredients commit f22b25e3233b4645dabd0d81e651fe074bd8e73b -Author: Vlad Dracula +Author: Alfredo Linguini Date: Thu Aug 22 09:51:46 2013 -0400 - Start notes on Mars as a base + Create a template for recipe ``` ::::::::::::::::::::::::::::::::::::::::: callout @@ -498,10 +515,10 @@ $ git log -1 ```output commit 005937fbe2a98fb83f0ade869025dc2636b4dad5 (HEAD -> main) -Author: Vlad Dracula +Author: Alfredo Linguini Date: Thu Aug 22 10:14:07 2013 -0400 - Discuss concerns about Mars' climate for Mummy + Modify guacamole to the traditional recipe ``` You can also reduce the quantity of information using the @@ -512,9 +529,9 @@ $ git log --oneline ``` ```output -005937f (HEAD -> main) Discuss concerns about Mars' climate for Mummy -34961b1 Add concerns about effects of Mars' moons on Wolfman -f22b25e Start notes on Mars as a base +005937f (HEAD -> main) Modify guacamole to the traditional recipe +34961b1 Add basic guacamole's ingredients +f22b25e Create a template for recipe ``` You can also combine the `--oneline` option with others. One useful @@ -528,9 +545,9 @@ $ git log --oneline --graph ``` ```output -* 005937f (HEAD -> main) Discuss concerns about Mars' climate for Mummy -* 34961b1 Add concerns about effects of Mars' moons on Wolfman -* f22b25e Start notes on Mars as a base +* 005937f (HEAD -> main) Modify guacamole to the traditional recipe +* 34961b1 Add basic guacamole's ingredients +* f22b25e Create a template for recipe ``` :::::::::::::::::::::::::::::::::::::::::::::::::: @@ -545,13 +562,13 @@ Two important facts you should know about directories in Git. Try it for yourself: ```bash - $ mkdir spaceships + $ mkdir cakes $ git status - $ git add spaceships + $ git add cakes $ git status ``` - Note, our newly created empty directory `spaceships` does not appear in + Note, our newly created empty directory `cakes` does not appear in the list of untracked files even if we explicitly add it (*via* `git add`) to our repository. This is the reason why you will sometimes see `.gitkeep` files in otherwise empty directories. Unlike `.gitignore`, these files are not special @@ -568,16 +585,16 @@ Two important facts you should know about directories in Git. Try it for yourself: ```bash - $ touch spaceships/apollo-11 spaceships/sputnik-1 + $ touch cakes/brownie cakes/lemon_drizzle $ git status - $ git add spaceships + $ git add cakes $ git status ``` Before moving on, we will commit these changes. ```bash - $ git commit -m "Add some initial thoughts on spaceships" + $ git commit -m "Add some initial cakes" ``` :::::::::::::::::::::::::::::::::::::::::::::::::: @@ -594,11 +611,11 @@ repository (`git commit`): ## Choosing a Commit Message Which of the following commit messages would be most appropriate for the -last commit made to `mars.txt`? +last commit made to `guacamole.md`? 1. "Changes" -2. "Added line 'But the Mummy will appreciate the lack of humidity' to mars.txt" -3. "Discuss effects of Mars' climate on the Mummy" +2. "Changed lemon for lime" +3. "Guacamole modified to the traditional recipe" ::::::::::::::: solution @@ -658,10 +675,10 @@ to my local Git repository? The staging area can hold changes from any number of files that you want to commit as a single snapshot. -1. Add some text to `mars.txt` noting your decision - to consider Venus as a base -2. Create a new file `venus.txt` with your initial thoughts - about Venus as a base for you and your friends +1. Add some text to `guacamole.md` noting the rough price of the + ingredients. +2. Create a new file `groceries.md` with a list of products and + their prices for different markets. 3. Add changes from both files to the staging area, and commit those changes. @@ -669,53 +686,56 @@ that you want to commit as a single snapshot. ## Solution -The output below from `cat mars.txt` reflects only content added during -this exercise. Your output may vary. - -First we make our changes to the `mars.txt` and `venus.txt` files: +First we make our changes to the `guacamole.md` and `groceries.md` files: ```bash -$ nano mars.txt -$ cat mars.txt +$ nano guacamole.md +$ cat guacamole.md ``` ```output -Maybe I should start with a base on Venus. +# Ingredients +- avocado (1.35) +- lime (0.64) +- salt (2) ``` ```bash -$ nano venus.txt -$ cat venus.txt +$ nano groceries.md +$ cat groceries.md ``` ```output -Venus is a nice planet and I definitely should consider it as a base. +# Market A +- avocado: 1.35 per unit. +- lime: 0.64 per unit +- salt: 2 per kg ``` Now you can add both files to the staging area. We can do that in one line: ```bash -$ git add mars.txt venus.txt +$ git add guacamole.md groceries.md ``` Or with multiple commands: ```bash -$ git add mars.txt -$ git add venus.txt +$ git add guacamole.md +$ git add groceries.md ``` Now the files are ready to commit. You can check that using `git status`. If you are ready to commit use: ```bash -$ git commit -m "Write plans to start a base on Venus" +$ git commit -m "Write prices for ingredients and their source" ``` ```output [main cc127c2] - Write plans to start a base on Venus - 2 files changed, 2 insertions(+) - create mode 100644 venus.txt + Write prices for ingredients and their source + 2 files changed, 7 insertions(+) + create mode 100644 groceries.md ``` ::::::::::::::::::::::::: @@ -737,7 +757,7 @@ $ git commit -m "Write plans to start a base on Venus" ## Solution -If needed, move out of the `planets` folder: +If needed, move out of the `recipes` folder: ```bash $ cd .. @@ -761,7 +781,7 @@ Once in place, add and commit it to the repository: ```bash $ git add me.txt -$ git commit -m "Add biography file" +$ git commit -m "Add biography file" ``` Modify the file as described (modify one line, add a fourth line). diff --git a/episodes/05-history.md b/episodes/05-history.md index fcfbd1364f..4df418f5ce 100644 --- a/episodes/05-history.md +++ b/episodes/05-history.md @@ -25,38 +25,40 @@ As we saw in the previous episode, we can refer to commits by their identifiers. You can refer to the *most recent commit* of the working directory by using the identifier `HEAD`. -We've been adding one line at a time to `mars.txt`, so it's easy to track our +We've been adding small changes at a time to `guacamole.md`, so it's easy to track our progress by looking, so let's do that using our `HEAD`s. Before we start, -let's make a change to `mars.txt`, adding yet another line. +let's make a change to `guacamole.md`, adding yet another line. ```bash -$ nano mars.txt -$ cat mars.txt +$ nano guacamole.md +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color -The two moons may be a problem for Wolfman -But the Mummy will appreciate the lack of humidity +# Ingredients +- avocado +- lime +- salt +# Instructions An ill-considered change ``` Now, let's see what we get. ```bash -$ git diff HEAD mars.txt +$ git diff HEAD guacamole.md ``` ```output -diff --git a/mars.txt b/mars.txt +diff --git a/guacamole.md b/guacamole.md index b36abfd..0848c8d 100644 ---- a/mars.txt -+++ b/mars.txt -@@ -1,3 +1,4 @@ - Cold and dry, but everything is my favorite color - The two moons may be a problem for Wolfman - But the Mummy will appreciate the lack of humidity -+An ill-considered change. +--- a/guacamole.md ++++ b/guacamole.md +@@ -3,3 +3,4 @@ + - lime + - salt + # Instructions ++An ill-considered change ``` which is the same as what you would get if you leave out `HEAD` (try it). The @@ -66,26 +68,27 @@ that by adding `~1` to refer to the commit one before `HEAD`. ```bash -$ git diff HEAD~1 mars.txt +$ git diff HEAD~1 guacamole.md ``` If we want to see the differences between older commits we can use `git diff` again, but with the notation `HEAD~1`, `HEAD~2`, and so on, to refer to them: ```bash -$ git diff HEAD~3 mars.txt +$ git diff HEAD~2 guacamole.md ``` ```output -diff --git a/mars.txt b/mars.txt +diff --git a/guacamole.md b/guacamole.md index df0654a..b36abfd 100644 ---- a/mars.txt -+++ b/mars.txt -@@ -1 +1,4 @@ - Cold and dry, but everything is my favorite color -+The two moons may be a problem for Wolfman -+But the Mummy will appreciate the lack of humidity -+An ill-considered change +--- a/guacamole.md ++++ b/guacamole.md +@@ -1,2 +1,5 @@ + # Ingredients ++- avocado ++- lime ++- salt + # Instructions ``` We could also use `git show` which shows us what changes we made at an older commit as @@ -93,23 +96,24 @@ well as the commit message, rather than the *differences* between a commit and o working directory that we see by using `git diff`. ```bash -$ git show HEAD~3 mars.txt +$ git show HEAD~2 guacamole.md ``` ```output commit f22b25e3233b4645dabd0d81e651fe074bd8e73b -Author: Vlad Dracula -Date: Thu Aug 22 09:51:46 2013 -0400 +Author: Alfredo Linguini +Date: Thu Aug 22 10:07:21 2013 -0400 - Start notes on Mars as a base + Create a template for recipe -diff --git a/mars.txt b/mars.txt +diff --git a/guacamole.md b/guacamole.md new file mode 100644 index 0000000..df0654a --- /dev/null -+++ b/mars.txt -@@ -0,0 +1 @@ -+Cold and dry, but everything is my favorite color ++++ b/guacamole.md +@@ -0,0 +1,2 @@ ++# Ingredients ++# Instructions ``` In this way, @@ -132,18 +136,20 @@ Our first commit was given the ID so let's try this: ```bash -$ git diff f22b25e3233b4645dabd0d81e651fe074bd8e73b mars.txt +$ git diff f22b25e3233b4645dabd0d81e651fe074bd8e73b guacamole.md ``` ```output -diff --git a/mars.txt b/mars.txt +diff --git a/guacamole.md b/guacamole.md index df0654a..93a3e13 100644 ---- a/mars.txt -+++ b/mars.txt -@@ -1 +1,4 @@ - Cold and dry, but everything is my favorite color -+The two moons may be a problem for Wolfman -+But the Mummy will appreciate the lack of humidity +--- a/guacamole.md ++++ b/guacamole.md +@@ -1,2 +1,5 @@ + # Ingredients ++- avocado ++- lime ++- salt + # Instructions +An ill-considered change ``` @@ -152,18 +158,20 @@ but typing out random 40-character strings is annoying, so Git lets us use just the first few characters (typically seven for normal size projects): ```bash -$ git diff f22b25e mars.txt +$ git diff f22b25e guacamole.md ``` ```output -diff --git a/mars.txt b/mars.txt +diff --git a/guacamole.md b/guacamole.md index df0654a..93a3e13 100644 ---- a/mars.txt -+++ b/mars.txt -@@ -1 +1,4 @@ - Cold and dry, but everything is my favorite color -+The two moons may be a problem for Wolfman -+But the Mummy will appreciate the lack of humidity +--- a/guacamole.md ++++ b/guacamole.md +@@ -1,2 +1,5 @@ + # Ingredients ++- avocado ++- lime ++- salt + # Instructions +An ill-considered change ``` @@ -171,7 +179,7 @@ All right! So we can save changes to files and see what we've changed. Now, how can we restore older versions of things? Let's suppose we change our mind about the last update to -`mars.txt` (the "ill-considered change"). +`guacamole.md` (the "ill-considered change"). `git status` now tells us that the file has been changed, but those changes haven't been staged: @@ -186,7 +194,7 @@ Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) - modified: mars.txt + modified: guacamole.md no changes added to commit (use "git add" and/or "git commit -a") ``` @@ -195,14 +203,16 @@ We can put things back the way they were by using `git checkout`: ```bash -$ git checkout HEAD mars.txt -$ cat mars.txt +$ git checkout HEAD guacamole.md +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color -The two moons may be a problem for Wolfman -But the Mummy will appreciate the lack of humidity +# Ingredients +- avocado +- lime +- salt +# Instructions ``` As you might guess from its name, @@ -214,15 +224,16 @@ If we want to go back even further, we can use a commit identifier instead: ```bash -$ git checkout f22b25e mars.txt +$ git checkout f22b25e guacamole.md ``` ```bash -$ cat mars.txt +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color +# Ingredients +# Instructions ``` ```bash @@ -234,7 +245,7 @@ On branch main Changes to be committed: (use "git reset HEAD ..." to unstage) - modified: mars.txt + modified: guacamole.md ``` @@ -243,7 +254,7 @@ Again, we can put things back the way they were by using `git checkout`: ```bash -$ git checkout HEAD mars.txt +$ git checkout HEAD guacamole.md ``` ::::::::::::::::::::::::::::::::::::::::: callout @@ -253,13 +264,13 @@ $ git checkout HEAD mars.txt Above we used ```bash -$ git checkout f22b25e mars.txt +$ git checkout f22b25e guacamole.md ``` -to revert `mars.txt` to its state after the commit `f22b25e`. But be careful! +to revert `guacamole.md` to its state after the commit `f22b25e`. But be careful! The command `checkout` has other important functionalities and Git will misunderstand your intentions if you are not accurate with the typing. For example, -if you forget `mars.txt` in the previous command. +if you forget `guacamole.md` in the previous command. ```bash $ git checkout f22b25e @@ -277,7 +288,7 @@ do so (now or later) by using -b with the checkout command again. Example: git checkout -b -HEAD is now at f22b25e Start notes on Mars as a base +HEAD is now at f22b25e Create a template for recipe ``` The "detached HEAD" is like "look, but don't touch" here, @@ -309,7 +320,7 @@ here's how Git works in cartoon form: If you read the output of `git status` carefully, you'll see that it includes this hint: -```output +```bash (use "git checkout -- ..." to discard changes in working directory) ``` @@ -432,27 +443,27 @@ else has committed changes to the repository. What is the output of the last command in ```bash -$ cd planets -$ echo "Venus is beautiful and full of love" > venus.txt -$ git add venus.txt -$ echo "Venus is too hot to be suitable as a base" >> venus.txt -$ git commit -m "Comment on Venus as an unsuitable base" -$ git checkout HEAD venus.txt -$ cat venus.txt #this will print the contents of venus.txt to the screen +$ cd recipes +$ echo "I like tomatos, therefore I like ketchup" > ketchup.md +$ git add ketchup.md +$ echo "ketchup enchances pasta dishes" > ketchup.md +$ git commit -m "my opinions about the red sauce" +$ git checkout HEAD ketchup.md +$ cat ketchup.md # this will print the content of ketchup.md on screen ``` 1. ```output - Venus is too hot to be suitable as a base + ketchup enchances pasta dishes ``` 2. ```output - Venus is beautiful and full of love + I like tomatos, therefore I like ketchup ``` 3. ```output - Venus is beautiful and full of love - Venus is too hot to be suitable as a base + I like tomatos, therefore I like ketchup + ketchup enchances pasta dishes ``` 4. ```output - Error because you have changed venus.txt without committing the changes + Error because you have changed ketchup.md without committing the changes ``` ::::::::::::::: solution @@ -461,22 +472,22 @@ $ cat venus.txt #this will print the contents of venus.txt to the screen The answer is 2. -The command `git add venus.txt` places the current version of `venus.txt` into the staging area. The changes to the file from the second `echo` command are only applied to the working copy, +The command `git add ketchup.md` places the current version of `ketchup.md` into the staging area. not the version in the staging area. -So, when `git commit -m "Comment on Venus as an unsuitable base"` is executed, -the version of `venus.txt` committed to the repository is the one from the staging area and +So, when `git commit -m "my opinions about the red sauce"` is executed, +the version of `ketchup.md` committed to the repository is the one from the staging area and has only one line. At this time, the working copy still has the second line (and -`git status` will show that the file is modified). However, `git checkout HEAD venus.txt` -replaces the working copy with the most recently committed version of `venus.txt`. -So, `cat venus.txt` will output +`git status` will show that the file is modified). However, `git checkout HEAD ketchup.md` +replaces the working copy with the most recently committed version of `ketchup.md`. +So, `cat ketchup.md` will output ```output -Venus is beautiful and full of love. +I like tomatos, therefore I like ketchup ``` ::::::::::::::::::::::::: @@ -487,10 +498,10 @@ Venus is beautiful and full of love. ## Checking Understanding of `git diff` -Consider this command: `git diff HEAD~9 mars.txt`. What do you predict this command +Consider this command: `git diff HEAD~9 guacamole.md`. What do you predict this command will do if you execute it? What happens when you do execute it? Why? -Try another command, `git diff [ID] mars.txt`, where [ID] is replaced with +Try another command, `git diff [ID] guacamole.md`, where [ID] is replaced with the unique identifier for your most recent commit. What do you think will happen, and what does happen? @@ -503,7 +514,7 @@ and what does happen? `git checkout` can be used to restore a previous commit when unstaged changes have been made, but will it also work for changes that have been staged but not committed? -Make a change to `mars.txt`, add that change using `git add`, +Make a change to `guacamole.md`, add that change using `git add`, then use `git checkout` to see if you can remove your change. ::::::::::::::: solution @@ -518,7 +529,7 @@ On branch main Changes to be committed: (use "git reset HEAD ..." to unstage) - modified: mars.txt + modified: guacamole.md ``` @@ -526,19 +537,19 @@ Note that if you don't have the same output you may either have forgotten to change the file, or you have added it *and* committed it. -Using the command `git checkout -- mars.txt` now does not give an error, +Using the command `git checkout -- guacamole.md` now does not give an error, but it does not restore the file either. Git helpfully tells us that we need to use `git reset` first to unstage the file: ```bash -$ git reset HEAD mars.txt +$ git reset HEAD guacamole.md ``` ```output Unstaged changes after reset: -M mars.txt -``` +M guacamole.md + Now, `git status` gives us: @@ -552,7 +563,7 @@ Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) - modified: mars.txt + modified: guacamole.md no changes added to commit (use "git add" and/or "git commit -a") ``` @@ -561,7 +572,7 @@ This means we can now use `git checkout` to restore the file to the previous commit: ```bash -$ git checkout -- mars.txt +$ git checkout -- guacamole.md $ git status ``` @@ -581,16 +592,16 @@ nothing to commit, working tree clean Exploring history is an important part of Git, and often it is a challenge to find the right commit ID, especially if the commit is from several months ago. -Imagine the `planets` project has more than 50 files. -You would like to find a commit that modifies some specific text in `mars.txt`. +Imagine the `recipes` project has more than 50 files. +You would like to find a commit that modifies some specific text in `guacamole.md`. When you type `git log`, a very long list appeared. How can you narrow down the search? Recall that the `git diff` command allows us to explore one specific file, -e.g., `git diff mars.txt`. We can apply a similar idea here. +e.g., `git diff guacamole.md`. We can apply a similar idea here. ```bash -$ git log mars.txt +$ git log guacamole.md ``` Unfortunately some of these commit messages are very ambiguous, e.g., `update files`. @@ -601,7 +612,7 @@ for you. Is it possible to combine both? Let's try the following: ```bash -$ git log --patch mars.txt +$ git log --patch guacamole.md ``` You should get a long list of output, and you should be able to see both commit messages and @@ -610,7 +621,7 @@ the difference between each commit. Question: What does the following command do? ```bash -$ git log --patch HEAD~9 *.txt +$ git log --patch HEAD~9 *.md ``` :::::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/episodes/06-ignore.md b/episodes/06-ignore.md index bb98f510ec..6eb5a7be9f 100644 --- a/episodes/06-ignore.md +++ b/episodes/06-ignore.md @@ -23,8 +23,8 @@ or intermediate files created during data analysis? Let's create a few dummy files: ```bash -$ mkdir results -$ touch a.dat b.dat c.dat results/a.out results/b.out +$ mkdir receipts +$ touch a.png b.png c.png receipts/a.jpg receipts/b.jpg ``` and see what Git says: @@ -38,10 +38,10 @@ On branch main Untracked files: (use "git add ..." to include in what will be committed) - a.dat - b.dat - c.dat - results/ + a.png + b.png + c.png + receipts/ nothing added to commit but untracked files present (use "git add" to track) ``` @@ -59,12 +59,12 @@ $ cat .gitignore ``` ```output -*.dat -results/ +*.png +receipts/ ``` -These patterns tell Git to ignore any file whose name ends in `.dat` -and everything in the `results` directory. +These patterns tell Git to ignore any file whose name ends in `.png` +and everything in the `receipts` directory. (If any of these files were already being tracked, Git would continue to track them.) @@ -93,7 +93,7 @@ Let's add and commit `.gitignore`: ```bash $ git add .gitignore -$ git commit -m "Ignore data files and the results folder" +$ git commit -m "Ignore png files and the receipts folder." $ git status ``` @@ -105,12 +105,12 @@ nothing to commit, working tree clean As a bonus, using `.gitignore` helps us avoid accidentally adding files to the repository that we don't want to track: ```bash -$ git add a.dat +$ git add a.png ``` ```output The following paths are ignored by one of your .gitignore files: -a.dat +a.png Use -f if you really want to add them. ``` @@ -128,10 +128,10 @@ On branch main Ignored files: (use "git add -f ..." to include in what will be committed) - a.dat - b.dat - c.dat - results/ + a.png + b.png + c.png + receipts/ nothing to commit, working tree clean ``` @@ -143,27 +143,27 @@ nothing to commit, working tree clean Given a directory structure that looks like: ```bash -results/data -results/plots +receipts/data +receipts/plots ``` -How would you ignore only `results/plots` and not `results/data`? +How would you ignore only `receipts/plots` and not `receipts/data`? ::::::::::::::: solution ## Solution If you only want to ignore the contents of -`results/plots`, you can change your `.gitignore` to ignore +`receipts/plots`, you can change your `.gitignore` to ignore only the `/plots/` subfolder by adding the following line to your .gitignore: ```output -results/plots/ +receipts/plots/ ``` -This line will ensure only the contents of `results/plots` is ignored, and -not the contents of `results/data`. +This line will ensure only the contents of `receipts/plots` is ignored, and +not the contents of `receipts/data`. As with most programming issues, there are a few alternative ways that one may ensure this ignore rule is followed. @@ -182,8 +182,8 @@ Further, the discussion page has more detail on ignore rules. ## Including Specific Files -How would you ignore all `.dat` files in your root directory except for -`final.dat`? +How would you ignore all `.png` files in your root directory except for +`final.png`? Hint: Find out what `!` (the exclamation point operator) does ::::::::::::::: solution @@ -193,15 +193,15 @@ Hint: Find out what `!` (the exclamation point operator) does You would add the following two lines to your .gitignore: ```output -*.dat # ignore all data files -!final.dat # except final.data +*.png # ignore all png files +!final.png # except final.png ``` The exclamation point operator will include a previously excluded entry. -Note also that because you've previously committed `.dat` files in this +Note also that because you've previously committed `.png` files in this lesson they will not be ignored with this new rule. Only future additions -of `.dat` files added to the root directory will be ignored. +of `.png` files added to the root directory will be ignored. @@ -217,13 +217,13 @@ Given a directory structure that looks similar to the earlier Nested Files exercise, but with a slightly different directory structure: ```bash -results/data -results/images -results/plots -results/analysis +receipts/data +receipts/images +receipts/plots +receipts/analysis ``` -How would you ignore all of the contents in the results folder, but not `results/data`? +How would you ignore all of the contents in the receipts folder, but not `receipts/data`? Hint: think a bit about how you created an exception with the `!` operator before. @@ -233,13 +233,13 @@ before. ## Solution If you want to ignore the contents of -`results/` but not those of `results/data/`, you can change your `.gitignore` to ignore -the contents of results folder, but create an exception for the contents of the -`results/data` subfolder. Your .gitignore would look like this: +`receipts/` but not those of `receipts/data/`, you can change your `.gitignore` to ignore +the contents of receipts folder, but create an exception for the contents of the +`receipts/data` subfolder. Your .gitignore would look like this: ```output -results/* # ignore everything in results folder -!results/data/ # do not ignore results/data/ contents +receipts/* # ignore everything in receipts folder +!receipts/data/ # do not ignore receipts/data/ contents ``` ::::::::::::::::::::::::: @@ -253,23 +253,23 @@ results/* # ignore everything in results folder Assuming you have an empty .gitignore file, and given a directory structure that looks like: ```bash -results/data/position/gps/a.dat -results/data/position/gps/b.dat -results/data/position/gps/c.dat -results/data/position/gps/info.txt -results/plots +receipts/data/market_position/gps/a.dat +receipts/data/market_position/gps/b.dat +receipts/data/market_position/gps/c.dat +receipts/data/market_position/gps/info.txt +receipts/plots ``` What's the shortest `.gitignore` rule you could write to ignore all `.dat` -files in `result/data/position/gps`? Do not ignore the `info.txt`. +files in `result/data/market_position/gps`? Do not ignore the `info.txt`. ::::::::::::::: solution ## Solution -Appending `results/data/position/gps/*.dat` will match every file in `results/data/position/gps` +Appending `receipts/data/market_position/gps/*.dat` will match every file in `receipts/data/market_position/gps` that ends with `.dat`. -The file `results/data/position/gps/info.txt` will not be ignored. +The file `receipts/data/market_position/gps/info.txt` will not be ignored. diff --git a/episodes/07-github.md b/episodes/07-github.md index 073bed74cc..07fbdfc6f2 100644 --- a/episodes/07-github.md +++ b/episodes/07-github.md @@ -34,11 +34,11 @@ world. To this end we are going to create a *remote* repository that will be lin ## 1\. Create a remote repository Log in to [GitHub](https://github.com), then click on the icon in the top right corner to -create a new repository called `planets`: +create a new repository called `recipes`: ![](fig/github-create-repo-01.png){alt='Creating a Repository on GitHub (Step 1)'} -Name your repository "planets" and then click "Create Repository". +Name your repository "recipes" and then click "Create Repository". Note: Since this repository will be connected to a local repository, it needs to be empty. Leave "Initialize this repository with a README" unchecked, and keep "None" as options for both "Add @@ -55,13 +55,13 @@ information on how to configure your local repository: This effectively does the following on GitHub's servers: ```bash -$ mkdir planets -$ cd planets +$ mkdir recipes +$ cd recipes $ git init ``` If you remember back to the earlier [episode](04-changes.md) where we added and -committed our earlier work on `mars.txt`, we had a diagram of the local repository +committed our earlier work on `guacamole.md`, we had a diagram of the local repository which looked like this: ![](fig/git-staging-area.svg){alt='The Local Repository with Git Staging Area'} @@ -70,7 +70,7 @@ Now that we have two repositories, we need a diagram like this: ![](fig/git-freshly-made-github-repo.svg){alt='Freshly-Made GitHub Repository'} -Note that our local repository still contains our earlier work on `mars.txt`, but the +Note that our local repository still contains our earlier work on `guacamole.md`, but the remote repository on GitHub appears empty as it doesn't contain any files yet. ## 2\. Connect local to remote repository @@ -90,22 +90,23 @@ Click on the 'SSH' link to change the [protocol](../learners/reference.md#protoc We use SSH here because, while it requires some additional configuration, it is a security protocol widely used by many applications. The steps below describe SSH at a -minimum level for GitHub. +minimum level for GitHub. A supplemental episode to this lesson discusses advanced setup +and concepts of SSH and key pairs, and other material supplemental to git related SSH. :::::::::::::::::::::::::::::::::::::::::::::::::: ![](fig/github-change-repo-string.png){alt='Changing the Repository URL on GitHub'} -Copy that URL from the browser, go into the local `planets` repository, and run +Copy that URL from the browser, go into the local `recipes` repository, and run this command: ```bash -$ git remote add origin git@github.com:vlad/planets.git +$ git remote add origin git@github.com:alflin/recipes.git ``` -Make sure to use the URL for your repository rather than Vlad's: the only -difference should be your username instead of `vlad`. +Make sure to use the URL for your repository rather than Alfredo's: the only +difference should be your username instead of `alflin`. `origin` is a local name used to refer to the remote repository. It could be called anything, but `origin` is a convention that is often used by default in git @@ -118,8 +119,8 @@ $ git remote -v ``` ```output -origin git@github.com:vlad/planets.git (fetch) -origin git@github.com:vlad/planets.git (push) +origin git@github.com:alflin/recipes.git (fetch) +origin git@github.com:alflin/recipes.git (push) ``` We'll discuss remotes in more detail in the next episode, while @@ -127,7 +128,7 @@ talking about how they might be used for collaboration. ## 3\. SSH Background and Setup -Before Dracula can connect to a remote repository, he needs to set up a way for his computer to authenticate with GitHub so it knows it's him trying to connect to his remote repository. +Before Alfredo can connect to a remote repository, he needs to set up a way for his computer to authenticate with GitHub so it knows it's him trying to connect to his remote repository. We are going to set up the method that is commonly used by many different services to authenticate access on the command line. This method is called Secure Shell Protocol (SSH). SSH is a cryptographic network protocol that allows secure communication between computers using an otherwise insecure network. @@ -167,21 +168,21 @@ ls -al ~/.ssh Your output is going to look a little different depending on whether or not SSH has ever been set up on the computer you are using. -Dracula has not set up SSH on his computer, so his output is +Alfredo has not set up SSH on his computer, so his output is ```output -ls: cannot access '/c/Users/Vlad Dracula/.ssh': No such file or directory +ls: cannot access '/c/Users/Alfredo/.ssh': No such file or directory ``` -If SSH has been set up on the computer you're using, the public and private key pairs will be listed. The file names are either `id_ed25519`/`id_ed25519.pub` or `id_rsa`/`id_rsa.pub` depending on how the key pairs were set up. -Since they don't exist on Dracula's computer, he uses this command to create them. +If SSH has been set up on the computer you're using, the public and private key pairs will be listed. The file names are either `id_ed25519`/`id_ed25519.pub` or `id_rsa`/`id_rsa.pub` depending on how the key pairs were set up. +Since they don't exist on Alfredo's computer, he uses this command to create them. ### 3\.1 Create an SSH key pair To create an SSH key pair Vlad uses this command, where the `-t` option specifies which type of algorithm to use and `-C` attaches a comment to the key (here, Vlad's email): ```bash -$ ssh-keygen -t ed25519 -C "vlad@tran.sylvan.ia" +$ ssh-keygen -t ed25519 -C "a.linguini@ratatouille.fr" ``` If you are using a legacy system that doesn't support the Ed25519 algorithm, use: @@ -189,17 +190,17 @@ If you are using a legacy system that doesn't support the Ed25519 algorithm, use ```output Generating public/private ed25519 key pair. -Enter file in which to save the key (/c/Users/Vlad Dracula/.ssh/id_ed25519): +Enter file in which to save the key (/c/Users/Alfredo/.ssh/id_ed25519): ``` We want to use the default file, so just press Enter. ```output -Created directory '/c/Users/Vlad Dracula/.ssh'. +Created directory '/c/Users/Alfredo/.ssh'. Enter passphrase (empty for no passphrase): ``` -Now, it is prompting Dracula for a passphrase. Since he is using his lab's laptop that other people sometimes have access to, he wants to create a passphrase. Be sure to use something memorable or save your passphrase somewhere, as there is no "reset my password" option. +Now, it is prompting Alfredo for a passphrase. Since he is using his kitchen's laptop that other people sometimes have access to, he wants to create a passphrase. Be sure to use something memorable or save your passphrase somewhere, as there is no "reset my password" option. ```output Enter same passphrase again: @@ -208,10 +209,10 @@ Enter same passphrase again: After entering the same passphrase a second time, we receive the confirmation ```output -Your identification has been saved in /c/Users/Vlad Dracula/.ssh/id_ed25519 -Your public key has been saved in /c/Users/Vlad Dracula/.ssh/id_ed25519.pub +Your identification has been saved in /c/Users/Alfredo/.ssh/id_ed25519 +Your public key has been saved in /c/Users/Alfredo/.ssh/id_ed25519.pub The key fingerprint is: -SHA256:SMSPIStNyA00KPxuYu94KpZgRAYjgt9g4BA4kFy3g1o vlad@tran.sylvan.ia +SHA256:SMSPIStNyA00KPxuYu94KpZgRAYjgt9g4BA4kFy3g1o a.linguini@ratatouille.fr The key's randomart image is: +--[ED25519 256]--+ |^B== o. | @@ -236,10 +237,10 @@ ls -al ~/.ssh ``` ```output -drwxr-xr-x 1 Vlad Dracula 197121 0 Jul 16 14:48 ./ -drwxr-xr-x 1 Vlad Dracula 197121 0 Jul 16 14:48 ../ --rw-r--r-- 1 Vlad Dracula 197121 419 Jul 16 14:48 id_ed25519 --rw-r--r-- 1 Vlad Dracula 197121 106 Jul 16 14:48 id_ed25519.pub +drwxr-xr-x 1 Alfredo 197121 0 Jul 16 14:48 ./ +drwxr-xr-x 1 Alfredo 197121 0 Jul 16 14:48 ../ +-rw-r--r-- 1 Alfredo 197121 419 Jul 16 14:48 id_ed25519 +-rw-r--r-- 1 Alfredo 197121 106 Jul 16 14:48 id_ed25519.pub ``` ### 3\.2 Copy the public key to GitHub @@ -269,12 +270,12 @@ cat ~/.ssh/id_ed25519.pub ``` ```output -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDmRA3d51X0uu9wXek559gfn6UFNF69yZjChyBIU2qKI vlad@tran.sylvan.ia +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDmRA3d51X0uu9wXek559gfn6UFNF69yZjChyBIU2qKI a.linguini@ratatouille.fr ``` Now, going to GitHub.com, click on your profile icon in the top right corner to get the drop-down menu. Click "Settings," then on the settings page, click "SSH and GPG keys," on the left side "Account settings" menu. Click the "New SSH key" button on the right side. Now, -you can add the title (Dracula uses the title "Vlad's Lab Laptop" so he can remember where the original key pair +you can add the title (Alfredo uses the title "Alfredo's Kitchen Laptop" so he can remember where the original key pair files are located), paste your SSH key into the field, and click the "Add SSH key" to complete the setup. Now that we've set that up, let's check our authentication again from the command line. @@ -284,7 +285,7 @@ $ ssh -T git@github.com ``` ```output -Hi Vlad! You've successfully authenticated, but GitHub does not provide shell access. +Hi Alfredo! You've successfully authenticated, but GitHub does not provide shell access. ``` Good! This output confirms that the SSH key works as intended. We are now ready to push our work to the remote repository. @@ -298,7 +299,7 @@ our local repository to the repository on GitHub: $ git push origin main ``` -Since Dracula set up a passphrase, it will prompt him for it. If you completed advanced settings for your authentication, it +Since Alfredo set up a passphrase, it will prompt him for it. If you completed advanced settings for your authentication, it will not prompt for a passphrase. ```output @@ -309,7 +310,7 @@ Compressing objects: 100% (11/11), done. Writing objects: 100% (16/16), 1.45 KiB | 372.00 KiB/s, done. Total 16 (delta 2), reused 0 (delta 0) remote: Resolving deltas: 100% (2/2), done. -To https://github.com/vlad/planets.git +To https://github.com/alflin/recipes.git * [new branch] main -> main ``` @@ -386,7 +387,7 @@ $ git pull origin main ``` ```output -From https://github.com/vlad/planets +From https://github.com/alflin/recipes * branch main -> FETCH_HEAD Already up-to-date. ``` @@ -399,7 +400,7 @@ GitHub, though, this command would download them to our local repository. ## GitHub GUI -Browse to your `planets` repository on GitHub. +Browse to your `recipes` repository on GitHub. Under the Code tab, find and click on the text that says "XX commits" (where "XX" is some number). Hover over, and click on, the three buttons to the right of each commit. What information can you gather/explore from these buttons? @@ -516,7 +517,7 @@ remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. -From https://github.com/vlad/planets +From https://github.com/alflin/recipes * branch main -> FETCH_HEAD * [new branch] main -> origin/main fatal: refusing to merge unrelated histories @@ -531,7 +532,7 @@ $ git pull --allow-unrelated-histories origin main ``` ```output -From https://github.com/vlad/planets +From https://github.com/alflin/recipes * branch main -> FETCH_HEAD Merge made by the 'recursive' strategy. README.md | 1 + diff --git a/episodes/08-collab.md b/episodes/08-collab.md index 279884b3ec..a0b0dd1454 100644 --- a/episodes/08-collab.md +++ b/episodes/08-collab.md @@ -48,21 +48,21 @@ or check for email notification. Once there she can accept access to the Owner's Next, the Collaborator needs to download a copy of the Owner's repository to her machine. This is called "cloning a repo". -The Collaborator doesn't want to overwrite her own version of `planets.git`, so +The Collaborator doesn't want to overwrite her own version of `recipes.git`, so needs to clone the Owner's repository to a different location than her own repository with the same name. To clone the Owner's repo into her `Desktop` folder, the Collaborator enters: ```bash -$ git clone git@github.com:vlad/planets.git ~/Desktop/vlad-planets +$ git clone git@github.com:alflin/recipes.git ~/Desktop/alflin-recipes ``` -Replace 'vlad' with the Owner's username. +Replace 'alflin' with the Owner's username. If you choose to clone without the clone path -(`~/Desktop/vlad-planets`) specified at the end, -you will clone inside your own planets folder! +(`~/Desktop/alflin-recipes`) specified at the end, +you will clone inside your own recipes folder! Make sure to navigate to the `Desktop` folder first. ![](fig/github-collaboration.svg){alt='After Creating Clone of Repository'} @@ -71,23 +71,27 @@ The Collaborator can now make a change in her clone of the Owner's repository, exactly the same way as we've been doing before: ```bash -$ cd ~/Desktop/vlad-planets -$ nano pluto.txt -$ cat pluto.txt +$ cd ~/Desktop/alflin-recipes +$ nano hummus.md +$ cat hummus.md ``` ```output -It is so a planet! +# Ingredients +- chickpeas +- lemon +- olive oil +- salt ``` ```bash -$ git add pluto.txt -$ git commit -m "Add notes about Pluto" +$ git add hummus.md +$ git commit -m "Add ingredients for hummus" ``` ```output - 1 file changed, 1 insertion(+) - create mode 100644 pluto.txt + 1 file changed, 5 insertion(+) + create mode 100644 hummus.md ``` Then push the change to the *Owner's repository* on GitHub: @@ -103,7 +107,7 @@ Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 306 bytes, done. Total 3 (delta 0), reused 0 (delta 0) -To https://github.com/vlad/planets.git +To https://github.com/alflin/recipes.git 9272da5..29aba7c main -> main ``` @@ -130,7 +134,7 @@ You would pull from `upstream` from time to time to get the latest updates that other people have committed. Remember that the name you give to a remote only exists locally. It's -an alias that you choose - whether `origin`, or `upstream`, or `fred` - +an alias that you choose - whether `origin`, or `upstream`, or `alfred` - and not something intrinstic to the remote repository. The `git remote` family of commands is used to set up and alter the remotes @@ -146,7 +150,7 @@ associated with a repository. Here are some of the most useful ones: account, or from GitHub to a different hosting service. Or, if we made a typo when adding it! - `git remote rename [oldname] [newname]` changes the local alias by which a remote - is known - its name. For example, one could use this to change `upstream` to `fred`. + is known - its name. For example, one could use this to change `upstream` to `alfred`. :::::::::::::::::::::::::::::::::::::::::::::::::: @@ -163,14 +167,14 @@ remote: Counting objects: 100% (4/4), done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. -From https://github.com/vlad/planets +From https://github.com/alflin/recipes * branch main -> FETCH_HEAD 9272da5..29aba7c main -> origin/main Updating 9272da5..29aba7c Fast-forward - pluto.txt | 1 + - 1 file changed, 1 insertion(+) - create mode 100644 pluto.txt + hummus.md | 5 + + 1 file changed, 5 insertion(+) + create mode 100644 hummus.md ``` Now the three repositories (Owner's local, Collaborator's local, and Owner's on diff --git a/episodes/09-conflict.md b/episodes/09-conflict.md index b1e9e0b3dc..6551a20846 100644 --- a/episodes/09-conflict.md +++ b/episodes/09-conflict.md @@ -25,42 +25,46 @@ different changes to each copy. Version control helps us manage these [resolve](../learners/reference.md#resolve) overlapping changes. To see how we can resolve conflicts, we must first create one. The file -`mars.txt` currently looks like this in both partners' copies of our `planets` +`guacamole.md` currently looks like this in both partners' copies of our `recipes` repository: ```bash -$ cat mars.txt +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color -The two moons may be a problem for Wolfman -But the Mummy will appreciate the lack of humidity +# Ingredients +- avocado +- lime +- salt +# Instructions ``` Let's add a line to the collaborator's copy only: ```bash -$ nano mars.txt -$ cat mars.txt +$ nano guacamole.md +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color -The two moons may be a problem for Wolfman -But the Mummy will appreciate the lack of humidity -This line added to Wolfman's copy +# Ingredients +- avocado +- lime +- salt +# Instructions +- put one avocado into a bowl. ``` and then push the change to GitHub: ```bash -$ git add mars.txt -$ git commit -m "Add a line in our home copy" +$ git add guacamole.md +$ git commit -m "First step on the instructions" ``` ```output -[main 5ae9631] Add a line in our home copy +[main 5ae9631] First step on the instructions 1 file changed, 1 insertion(+) ``` @@ -76,7 +80,7 @@ Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 331 bytes | 331.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0) remote: Resolving deltas: 100% (2/2), completed with 2 local objects. -To https://github.com/vlad/planets.git +To https://github.com/alflin/recipes.git 29aba7c..dabb4c8 main -> main ``` @@ -85,26 +89,28 @@ make a different change to their copy *without* updating from GitHub: ```bash -$ nano mars.txt -$ cat mars.txt +$ nano guacamole.md +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color -The two moons may be a problem for Wolfman -But the Mummy will appreciate the lack of humidity -We added a different line in the other copy +# Ingredients +- avocado +- lime +- salt +# Instructions +- peel the avocados ``` We can commit the change locally: ```bash -$ git add mars.txt -$ git commit -m "Add a line in my copy" +$ git add guacamole.md +$ git commit -m "Add first step" ``` ```output -[main 07ebc69] Add a line in my copy +[main 07ebc69] Add first step 1 file changed, 1 insertion(+) ``` @@ -115,9 +121,9 @@ $ git push origin main ``` ```output -To https://github.com/vlad/planets.git +To https://github.com/alflin/recipes.git ! [rejected] main -> main (fetch first) -error: failed to push some refs to 'https://github.com/vlad/planets.git' +error: failed to push some refs to 'https://github.com/alflin/recipes.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes @@ -143,14 +149,52 @@ remote: Counting objects: 100% (5/5), done. remote: Compressing objects: 100% (1/1), done. remote: Total 3 (delta 2), reused 3 (delta 2), pack-reused 0 Unpacking objects: 100% (3/3), done. -From https://github.com/vlad/planets +From https://github.com/alflin/recipes * branch main -> FETCH_HEAD 29aba7c..dabb4c8 main -> origin/main -Auto-merging mars.txt -CONFLICT (content): Merge conflict in mars.txt +Auto-merging guacamole.md +CONFLICT (content): Merge conflict in guacamole.md Automatic merge failed; fix conflicts and then commit the result. ``` +::::::::::::::::::::::::::::::::::::::::: callout + +## You may need to tell git what to do + +If you see the below in your output, git is asking what it should do. + +```output +hint: You have divergent branches and need to specify how to reconcile them. +hint: You can do so by running one of the following commands sometime before +hint: your next pull: +hint: +hint: git config pull.rebase false # merge (the default strategy) +hint: git config pull.rebase true # rebase +hint: git config pull.ff only # fast-forward only +hint: +hint: You can replace "git config" with "git config --global" to set a default +hint: preference for all repositories. You can also pass --rebase, --no-rebase, +hint: or --ff-only on the command line to override the configured default per +hint: invocation. +``` + +In newer versions of git it gives you the option of specifying different +behaviours when a pull would merge divergent branches. In our case we want +'the default strategy'. To use this strategy run the following command to +select it as the default thing git should do. + +```bash +$ git config pull.rebase false +``` + +Then attempt the pull again. + +```bash +$ git pull origin main +``` + +:::::::::::::::::::::::::::::::::::::::::::::::::: + The `git pull` command updates the local repository to include those changes already included in the remote repository. After the changes from remote branch have been fetched, Git detects that changes made to the local copy @@ -159,17 +203,19 @@ stop us from trampling on our previous work. The conflict is marked in in the affected file: ```bash -$ cat mars.txt +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color -The two moons may be a problem for Wolfman -But the Mummy will appreciate the lack of humidity +# Ingredients +- avocado +- lime +- salt +# Instructions <<<<<<< HEAD -We added a different line in the other copy +- peel the avocados ======= -This line added to Wolfman's copy +- put one avocado into a bowl. >>>>>>> dabb4c8c450e8475aee9b14b4383acc99f42af1d ``` @@ -187,22 +233,24 @@ or get rid of the change entirely. Let's replace both so that the file looks like this: ```bash -$ cat mars.txt +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color -The two moons may be a problem for Wolfman -But the Mummy will appreciate the lack of humidity -We removed the conflict on this line +# Ingredients +- avocado +- lime +- salt +# Instructions +- peel the avocados and put them into a bowl. ``` To finish merging, -we add `mars.txt` to the changes being made by the merge +we add `guacamole.md` to the changes being made by the merge and then commit: ```bash -$ git add mars.txt +$ git add guacamole.md $ git status ``` @@ -213,7 +261,7 @@ All conflicts fixed but you are still merging. Changes to be committed: - modified: mars.txt + modified: guacamole.md ``` @@ -239,7 +287,7 @@ Compressing objects: 100% (6/6), done. Writing objects: 100% (6/6), 645 bytes | 645.00 KiB/s, done. Total 6 (delta 4), reused 0 (delta 0) remote: Resolving deltas: 100% (4/4), completed with 2 local objects. -To https://github.com/vlad/planets.git +To https://github.com/alflin/recipes.git dabb4c8..2abf2b1 main -> main ``` @@ -257,26 +305,28 @@ remote: Counting objects: 100% (10/10), done. remote: Compressing objects: 100% (2/2), done. remote: Total 6 (delta 4), reused 6 (delta 4), pack-reused 0 Unpacking objects: 100% (6/6), done. -From https://github.com/vlad/planets +From https://github.com/alflin/recipes * branch main -> FETCH_HEAD dabb4c8..2abf2b1 main -> origin/main Updating dabb4c8..2abf2b1 Fast-forward - mars.txt | 2 +- + guacamole.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ``` We get the merged file: ```bash -$ cat mars.txt +$ cat guacamole.md ``` ```output -Cold and dry, but everything is my favorite color -The two moons may be a problem for Wolfman -But the Mummy will appreciate the lack of humidity -We removed the conflict on this line +# Ingredients +- avocado +- lime +- salt +# Instructions +- peel the avocados and put them into a bowl. ``` We don't need to merge again because Git knows someone has already done that. @@ -328,49 +378,49 @@ that is stored in version control? ## Solution -Let's try it. Suppose Dracula takes a picture of Martian surface and -calls it `mars.jpg`. +Let's try it. Suppose Alfredo takes a picture of its guacamole and +calls it `guacamole.jpg`. -If you do not have an image file of Mars available, you can create +If you do not have an image file of guacamole available, you can create a dummy binary file like this: ```bash -$ head -c 1024 /dev/urandom > mars.jpg -$ ls -lh mars.jpg +$ head --bytes 1024 /dev/urandom > guacamole.jpg +$ ls -lh guacamole.jpg ``` ```output --rw-r--r-- 1 vlad 57095 1.0K Mar 8 20:24 mars.jpg +-rw-r--r-- 1 alflin 57095 1.0K Mar 8 20:24 guacamole.jpg ``` `ls` shows us that this created a 1-kilobyte file. It is full of random bytes read from the special file, `/dev/urandom`. -Now, suppose Dracula adds `mars.jpg` to his repository: +Now, suppose Alfredo adds `guacamole.jpg` to his repository: ```bash -$ git add mars.jpg -$ git commit -m "Add picture of Martian surface" +$ git add guacamole.jpg +$ git commit -m "Add picture of guacamole" ``` ```output -[main 8e4115c] Add picture of Martian surface +[main 8e4115c] Add picture of guacamole 1 file changed, 0 insertions(+), 0 deletions(-) - create mode 100644 mars.jpg + create mode 100644 guacamole.jpg ``` -Suppose that Wolfman has added a similar picture in the meantime. -His is a picture of the Martian sky, but it is *also* called `mars.jpg`. -When Dracula tries to push, he gets a familiar message: +Suppose that Jimmy has added a similar picture in the meantime. +His is a picture of a guacamole with nachos, but it is *also* called `guacamole.jpg`. +When Alfredo tries to push, he gets a familiar message: ```bash $ git push origin main ``` ```output -To https://github.com/vlad/planets.git +To https://github.com/alflin/recipes.git ! [rejected] main -> main (fetch first) -error: failed to push some refs to 'https://github.com/vlad/planets.git' +error: failed to push some refs to 'https://github.com/alflin/recipes.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes @@ -393,20 +443,20 @@ remote: Counting objects: 3, done. remote: Compressing objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. -From https://github.com/vlad/planets.git +From https://github.com/alflin/recipes.git * branch main -> FETCH_HEAD 6a67967..439dc8c main -> origin/main -warning: Cannot merge binary files: mars.jpg (HEAD vs. 439dc8c08869c342438f6dc4a2b615b05b93c76e) -Auto-merging mars.jpg -CONFLICT (add/add): Merge conflict in mars.jpg +warning: Cannot merge binary files: guacamole.jpg (HEAD vs. 439dc8c08869c342438f6dc4a2b615b05b93c76e) +Auto-merging guacamole.jpg +CONFLICT (add/add): Merge conflict in guacamole.jpg Automatic merge failed; fix conflicts and then commit the result. ``` -The conflict message here is mostly the same as it was for `mars.txt`, but +The conflict message here is mostly the same as it was for `guacamole.md`, but there is one key additional line: ```output -warning: Cannot merge binary files: mars.jpg (HEAD vs. 439dc8c08869c342438f6dc4a2b615b05b93c76e) +warning: Cannot merge binary files: guacamole.jpg (HEAD vs. 439dc8c08869c342438f6dc4a2b615b05b93c76e) ``` Git cannot automatically insert conflict markers into an image as it does @@ -414,31 +464,31 @@ for text files. So, instead of editing the image file, we must check out the version we want to keep. Then we can add and commit this version. On the key line above, Git has conveniently given us commit identifiers -for the two versions of `mars.jpg`. Our version is `HEAD`, and Wolfman's +for the two versions of `guacamole.jpg`. Our version is `HEAD`, and Jimmy's version is `439dc8c0...`. If we want to use our version, we can use `git checkout`: ```bash -$ git checkout HEAD mars.jpg -$ git add mars.jpg -$ git commit -m "Use image of surface instead of sky" +$ git checkout HEAD guacamole.jpg +$ git add guacamole.jpg +$ git commit -m "Use image of just guacamole instead of with nachos" ``` ```output -[main 21032c3] Use image of surface instead of sky +[main 21032c3] Use image of just guacamole instead of with nachos ``` -If instead we want to use Wolfman's version, we can use `git checkout` with -Wolfman's commit identifier, `439dc8c0`: +If instead we want to use Jimmy's version, we can use `git checkout` with +Jimmy's commit identifier, `439dc8c0`: ```bash -$ git checkout 439dc8c0 mars.jpg -$ git add mars.jpg -$ git commit -m "Use image of sky instead of surface" +$ git checkout 439dc8c0 guacamole.jpg +$ git add guacamole.jpg +$ git commit -m "Use image of guacamole with nachos instead of just guacamole" ``` ```output -[main da21b34] Use image of sky instead of surface +[main da21b34] Use image of guacamole with nachos instead of just guacamole ``` We can also keep *both* images. The catch is that we cannot keep them @@ -447,29 +497,29 @@ and *rename* it, then add the renamed versions. First, check out each image and rename it: ```bash -$ git checkout HEAD mars.jpg -$ git mv mars.jpg mars-surface.jpg -$ git checkout 439dc8c0 mars.jpg -$ mv mars.jpg mars-sky.jpg +$ git checkout HEAD guacamole.jpg +$ git mv guacamole.jpg guacamole-only.jpg +$ git checkout 439dc8c0 guacamole.jpg +$ mv guacamole.jpg guacamole-nachos.jpg ``` -Then, remove the old `mars.jpg` and add the two new files: +Then, remove the old `guacamole.jpg` and add the two new files: ```bash -$ git rm mars.jpg -$ git add mars-surface.jpg -$ git add mars-sky.jpg -$ git commit -m "Use two images: surface and sky" +$ git rm guacamole.jpg +$ git add guacamole-only.jpg +$ git add guacamole-nachos.jpg +$ git commit -m "Use two images: just guacamole and with nachos" ``` ```output -[main 94ae08c] Use two images: surface and sky +[main 94ae08c] Use two images: just guacamole and with nachos 2 files changed, 0 insertions(+), 0 deletions(-) - create mode 100644 mars-sky.jpg - rename mars.jpg => mars-surface.jpg (100%) + create mode 100644 guacamole-nachos.jpg + rename guacamole.jpg => guacamole-only.jpg (100%) ``` -Now both images of Mars are checked into the repository, and `mars.jpg` +Now both images of guacamole are checked into the repository, and `guacamole.jpg` no longer exists. diff --git a/episodes/14-supplemental-rstudio.md b/episodes/14-supplemental-rstudio.md index cffe469af2..71eb237d83 100644 --- a/episodes/14-supplemental-rstudio.md +++ b/episodes/14-supplemental-rstudio.md @@ -31,7 +31,7 @@ project with Git. To get started using Git in RStudio, we create a new project: ![](fig/RStudio_screenshot_newproject.png){alt='RStudio screenshot showing the file menu dropdown with "New Project..." selected'} This opens a dialog asking us how we want to create the project. We have -some options here. Let's say that we want to use RStudio with the planets +some options here. Let's say that we want to use RStudio with the recipes repository that we already made. Since that repository lives in a directory on our computer, we choose the option "Existing Directory": @@ -84,7 +84,7 @@ Next, RStudio will ask which existing directory we want to use. Click ![](fig/RStudio_screenshot_navigateexisting.png) -Ta-da! We have created a new project in RStudio within the existing planets +Ta-da! We have created a new project in RStudio within the existing recipes repository. Notice the vertical "Git" menu in the menu bar. RStudio has recognized that the current directory is a Git repository, and gives us a number of tools to use Git: @@ -93,7 +93,7 @@ number of tools to use Git: To edit the existing files in the repository, we can click on them in the "Files" panel on the lower right. Now let's add some additional information -about Pluto: +about Hummus: ![](fig/RStudio_screenshot_editfiles.png) diff --git a/episodes/fig/git-freshly-made-github-repo.svg b/episodes/fig/git-freshly-made-github-repo.svg index 2d70ffd175..aa497cf0d0 100644 --- a/episodes/fig/git-freshly-made-github-repo.svg +++ b/episodes/fig/git-freshly-made-github-repo.svg @@ -81,7 +81,7 @@ x="16" font-size="13.5" id="text3502" - style="font-size:13.5px;font-family:Helvetica">https://github.com/vlad/planets.git + style="font-size:13.5px;font-family:Helvetica">https://github.com/alflin/recipes.git ~/vlad/planets + y="28.707001">~/alflin/recipes origin https://github.com/vlad/planets.git + style="font-size:10.80000019px;font-family:Consolas">origin https://github.com/alflin/recipes.git ~/vlad/planets + style="font-size:13.5px;font-family:Helvetica">~/alflin/recipes https://github.com/vlad/planets.git + y="278.707">https://github.com/alflin/recipes.git origin https://github.com/vlad/planets.git + x="0">origin https://github.com/alflin/recipes.git ~/wolfman/planets + transform="translate(16,28.707)">~/jimmy/recipes origin https://github.com/vlad/planets.git + style="font-size:10.80000019px;font-family:Consolas">origin https://github.com/alflin/recipes.git ~/vlad/planets + style="font-size:13.5px;font-family:Helvetica">~/alflin/recipes https://github.com/vlad/planets.git + style="font-size:13.5px;font-family:Helvetica">https://github.com/alflin/recipes.git nibiru.txt +$ echo "This is where we keep the secret sauce" > invisible.md ``` Now add to the repository like you have learned earlier: ```bash -$ git add nibiru.txt -$ git commit -m 'adding info on nibiru' +$ git add invisible.md +$ git commit -m 'adding secret sauce' $ git status ``` ```output On branch main -nothing to commit, working tree clean +nothing to commit, working directory clean ``` -Nibiru is not a real planet. That was a silly idea. Let us remove +Invisible ink is not a real food. That was a silly idea. Let us remove it from the disk and let Git know about it: ```bash -$ git rm nibiru.txt +$ git rm invisible.md $ git status ``` @@ -244,7 +251,7 @@ On branch main Changes to be committed: (use "git reset HEAD ..." to unstage) - deleted: nibiru.txt + deleted: invisible.md ``` @@ -254,7 +261,7 @@ in the new commit. The previous commit will still have the file, if you were to retrieve that specific commit. ```bash -$ git commit -m 'Removing info on Nibiru. It is not a real planet!' +$ git commit -m 'Removing info on Invisible ink. It is not an edible sauce!' ``` ## Removing a File with Unix @@ -265,15 +272,15 @@ Git is smart enough to notice the missing file. Let us recreate the file and commit it again. ```bash -$ echo "This is another name for fake planet X" > nibiru.txt -$ git add nibiru.txt -$ git commit -m 'adding nibiru again' +$ echo "This is anoher way to make invisible ink" > secret.md +$ git add secret.md +$ git commit -m 'adding invisible ink again' ``` Now we remove the file with Unix `rm`: ```bash -$ rm nibiru.txt +$ rm secret.md $ git status ``` @@ -283,18 +290,18 @@ Changes not staged for commit: (use "git add/rm ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) - deleted: nibiru.txt + deleted: secret.md no changes added to commit (use "git add" and/or "git commit -a") ``` -See how Git has noticed that the file `nibiru.txt` has been removed +See how Git has noticed that the file `secret.md` has been removed from the disk. The next step is to "stage" the removal of the file from the repository. This is done with the command `git rm` just as before. ```bash -$ git rm nibiru.txt +$ git rm secret.md $ git status ``` @@ -303,7 +310,7 @@ On branch main Changes to be committed: (use "git reset HEAD ..." to unstage) - deleted: nibiru.txt + deleted: secret.md ``` @@ -311,33 +318,32 @@ The change that was made in Unix has now been staged and needs to be committed. ```bash -$ git commit -m 'Removing info on Nibiru, again!' +$ git commit -m 'Removing info on invisible ink, again!' ``` ## Renaming a File Another common change when working on a project is to rename a file. -Create a file for the planet Krypton: +Create a file for the whitesauce recipe: ```bash -$ echo "Superman's home planet" > krypton.txt +$ echo "Very fun recipe to do" > whitesauce.md ``` Add it to the repository: ```bash -$ git add krypton.txt -$ git commit -m 'Adding planet Krypton' +$ git add whitesauce.md +$ git commit -m 'Adding white sauce recipe' ``` -We all know that Superman moved to Earth. Not that he had much -choice. Now his home planet is Earth. +We all know that white sauce has a more sophisticated name. -Rename the file `krypton.txt` to `earth.txt` with Git: +Rename the file `whitesauce.md` to `bechamel.md` with Git: ```bash -$ git mv krypton.txt earth.txt +$ git mv whitesauce.md bechamel.md $ git status ``` @@ -346,13 +352,13 @@ On branch main Changes to be committed: (use "git reset HEAD ..." to unstage) - renamed: krypton.txt -> earth.txt + renamed: whitesauce.md -> bechamel.md ``` The final step is commit our change to the repository: ```bash -$ git commit -m 'Superman's home is now Earth' +$ git commit -m 'Using the French name for the whitesauce' ``` ## Renaming a File with Unix @@ -364,15 +370,15 @@ this time with Unix `mv`. First, we need to recreate the `krypton.txt` file: ```bash -$ echo "Superman's home planet" > krypton.txt -$ git add krypton.txt -$ git commit -m 'Adding planet Krypton again.' +$ echo "Very fun recipe to do" > whitesauce.md +$ git add whitesauce.md +$ git commit -m 'Adding white sauce recipe' ``` Let us rename the file and see what Git can figured out by itself: ```bash -$ mv krypton.txt earth.txt +$ mv whitesauce.md bechamel.md $ git status ``` @@ -382,23 +388,23 @@ Changes not staged for commit: (use "git add/rm ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) - deleted: krypton.txt + deleted: whitesauce.md Untracked files: (use "git add ..." to include in what will be committed) - earth.txt + bechamel.md no changes added to commit (use "git add" and/or "git commit -a") ``` -Git has noticed that the file `krypton.txt` has disappeared from the -file system and a new file `earth.txt` has showed up. +Git has noticed that the file `whitesauce.md` has disappeared from the +file system and a new file `bechamel.md` has showed up. Add those changes to the staging area: ```bash -$ git add krypton.txt earth.txt +$ git add whitesauce.md bechamel.md $ git status ``` @@ -407,17 +413,17 @@ On branch main Changes to be committed: (use "git reset HEAD ..." to unstage) - renamed: krypton.txt -> earth.txt + renamed: whitesauce.md -> bechamel.md ``` -Notice how Git has now figured out that the `krypton.txt` has not +Notice how Git has now figured out that the `whitesauce.md` has not disappeared - it has simply been renamed. The final step, as before, is to commit our change to the repository: ```bash -$ git commit -m 'Superman's home is Earth, told you before.' +$ git commit -m 'Using the French name for the whitesauce' ``` ## Further .gitignore concepts From 15d56848c06b83c02366163bb0e8d978cbb19445 Mon Sep 17 00:00:00 2001 From: Martino Sorbaro Date: Wed, 3 Jul 2024 20:50:23 +0200 Subject: [PATCH 02/13] fixing the names for the changes in more recent commits --- episodes/07-github.md | 4 ++-- episodes/14-supplemental-rstudio.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/episodes/07-github.md b/episodes/07-github.md index e33c075fab..c267717f80 100644 --- a/episodes/07-github.md +++ b/episodes/07-github.md @@ -68,7 +68,7 @@ which looked like this: Now that we have two repositories, we need a diagram like this: -![](fig/git-freshly-made-github-repo.svg) {alt='A diagram illustrating how the GitHub "planets" repository is also a git repository like our local repository, but that it is currently empty'} +![](fig/git-freshly-made-github-repo.svg){alt='A diagram illustrating how the GitHub "recipes" repository is also a git repository like our local repository, but that it is currently empty'} Note that our local repository still contains our earlier work on `guacamole.md`, but the remote repository on GitHub appears empty as it doesn't contain any files yet. @@ -80,7 +80,7 @@ GitHub repository a [remote](../learners/reference.md#remote) for the local repo The home page of the repository on GitHub includes the URL string we need to identify it: -![](fig/github-find-repo-string.png){alt='Clicking the "Copy to Clipboard" button on GitHub to obtain the repository's URL'} +![](fig/github-find-repo-string.png){alt='Clicking the "Copy to Clipboard" button on GitHub to obtain the repository\'s URL'} Click on the 'SSH' link to change the [protocol](../learners/reference.md#protocol) from HTTPS to SSH. diff --git a/episodes/14-supplemental-rstudio.md b/episodes/14-supplemental-rstudio.md index b0f73bc0e1..0b31e26c93 100644 --- a/episodes/14-supplemental-rstudio.md +++ b/episodes/14-supplemental-rstudio.md @@ -82,7 +82,7 @@ to accept the Xcode license if you are using macOS. Next, RStudio will ask which existing directory we want to use. Click "Browse..." and navigate to the correct directory, then click "Create Project": -![](fig/RStudio_screenshot_navigateexisting.png){alt='RStudio window showing the "Create Project From Existing Directory" dialog. In the dialog, the project working directory has been set to "~/Desktop/planets"'} +![](fig/RStudio_screenshot_navigateexisting.png){alt='RStudio window showing the "Create Project From Existing Directory" dialog. In the dialog, the project working directory has been set to "~/Desktop/recipes"'} Ta-da! We have created a new project in RStudio within the existing recipes repository. Notice the vertical "Git" menu in the menu bar. RStudio has From b9264c5fa3c1d638ad2b176edf155d4f8c7c2e5f Mon Sep 17 00:00:00 2001 From: Martino Sorbaro Date: Thu, 4 Jul 2024 19:06:54 +0200 Subject: [PATCH 03/13] undo change to README --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3af28745b4..8d6ad1aa66 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,13 @@ [![Create a Slack Account with us](https://img.shields.io/badge/Create_Slack_Account-The_Carpentries-071159.svg)](https://slack-invite.carpentries.org/) [![Slack Status](https://img.shields.io/badge/Slack_Channel-swc--git-E01563.svg)](https://carpentries.slack.com/messages/C91JS49HD) -# # UCL's git-novice +# git-novice An introduction to version control for novices using Git. Please see [https://swcarpentry.github.io/git-novice/](https://swcarpentry.github.io/git-novice/) for a rendered version of this material, or [the lesson template documentation][lesson-example] for instructions on formatting, building, and submitting material. -## Maintainers: - -## Upstream +Maintainers: - [Kat Koziar][koziar_kat]: [@kekoziar](https://github.com/kekoziar) - [Martino Sorbaro][sorbaro_mart]: [@martinosorb](https://github.com/martinosorb) From 1eabd6bc6360c1468cebc351500f49f114e5a261 Mon Sep 17 00:00:00 2001 From: Martino Sorbaro Date: Fri, 5 Jul 2024 14:43:22 +0200 Subject: [PATCH 04/13] =?UTF-8?q?un-=F0=9F=8D=B8=20the=20lesson?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- episodes/03-create.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/episodes/03-create.md b/episodes/03-create.md index 4f4eb11b97..7d01119ec6 100644 --- a/episodes/03-create.md +++ b/episodes/03-create.md @@ -102,31 +102,31 @@ wording of the output might be slightly different. ## Places to Create Git Repositories Along with tracking information about recipes (the project we have already created), -Alfredo would also like to track information about cocktails. -Despite Jimmy's concerns, Alfredo creates a `cocktails` project inside his `recipes` +Alfredo would also like to track information about desserts specifically. +Despite Jimmy's concerns, Alfredo creates a `desserts` project inside his `recipes` project with the following sequence of commands: ```bash $ cd ~/Desktop # return to Desktop directory $ cd recipes # go into recipes directory, which is already a Git repository $ ls -a # ensure the .git subdirectory is still present in the recipes directory -$ mkdir cocktails # make a sub-directory recipes/cocktails -$ cd cocktails # go into cocktails subdirectory -$ git init # make the cocktails subdirectory a Git repository +$ mkdir desserts # make a sub-directory recipes/desserts +$ cd desserts # go into desserts subdirectory +$ git init # make the desserts subdirectory a Git repository $ ls -a # ensure the .git subdirectory is present indicating we have created a new Git repository ``` -Is the `git init` command, run inside the `cocktails` subdirectory, required for -tracking files stored in the `cocktails` subdirectory? +Is the `git init` command, run inside the `desserts` subdirectory, required for +tracking files stored in the `desserts` subdirectory? ::::::::::::::: solution ## Solution -No. Alfredo does not need to make the `cocktails` subdirectory a Git repository +No. Alfredo does not need to make the `desserts` subdirectory a Git repository because the `recipes` repository will track all files, sub-directories, and subdirectory files under the `recipes` directory. Thus, in order to track -all information about cocktails, Alfredo only needed to add the `cocktails` subdirectory +all information about desserts, Alfredo only needed to add the `desserts` subdirectory to the `recipes` directory. Additionally, Git repositories can interfere with each other if they are "nested": @@ -151,7 +151,7 @@ fatal: Not a git repository (or any of the parent directories): .git Jimmy explains to Alfredo how a nested repository is redundant and may cause confusion down the road. Alfredo would like to go back to a single git repository. How can Alfredo undo -his last `git init` in the `cocktails` subdirectory? +his last `git init` in the `desserts` subdirectory? ::::::::::::::: solution @@ -175,10 +175,10 @@ becomes another change that we will need to track, as we will see in the next ep Git keeps all of its files in the `.git` directory. To recover from this little mistake, Alfredo can remove the `.git` -folder in the cocktails subdirectory by running the following command from inside the `recipes` directory: +folder in the desserts subdirectory by running the following command from inside the `recipes` directory: ```bash -$ rm -rf cocktails/.git +$ rm -rf desserts/.git ``` But be careful! Running this command in the wrong directory will remove From 2c983e7c838139c78f3cf627d7366b4baf2f4937 Mon Sep 17 00:00:00 2001 From: Martino Sorbaro Date: Mon, 5 Aug 2024 10:57:13 +0200 Subject: [PATCH 05/13] Remove Dracula joke Co-authored-by: Toby Hodges --- episodes/03-create.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/episodes/03-create.md b/episodes/03-create.md index 7d01119ec6..c13ea4b2bf 100644 --- a/episodes/03-create.md +++ b/episodes/03-create.md @@ -103,7 +103,7 @@ wording of the output might be slightly different. Along with tracking information about recipes (the project we have already created), Alfredo would also like to track information about desserts specifically. -Despite Jimmy's concerns, Alfredo creates a `desserts` project inside his `recipes` +Alfredo creates a `desserts` project inside his `recipes` project with the following sequence of commands: ```bash From 21c9dac88408f5052ecc63c0b310ea71e8a6689d Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Wed, 14 Aug 2024 16:00:30 +0100 Subject: [PATCH 06/13] Replaces `-` for `*` as lists on markdown examples Markdown accepts either `-` or `*` however, in this material, the `-` causes confussion when looking at diffs as you'd get things like: ```diff - avocado -- lemon +- lime ``` making the `-` from the diff misunderstood with the `-` of the list. --- episodes/04-changes.md | 46 +++++++++++++++++++-------------------- episodes/05-history.md | 34 ++++++++++++++--------------- episodes/08-collab.md | 8 +++---- episodes/09-conflict.md | 48 ++++++++++++++++++++--------------------- 4 files changed, 68 insertions(+), 68 deletions(-) diff --git a/episodes/04-changes.md b/episodes/04-changes.md index 3cb39912a1..4468375ead 100644 --- a/episodes/04-changes.md +++ b/episodes/04-changes.md @@ -202,9 +202,9 @@ $ cat guacamole.md ```output # Ingredients -- avocado -- lemon -- salt +* avocado +* lemon +* salt # Instructions ``` @@ -248,9 +248,9 @@ index df0654a..315bf3a 100644 +++ b/guacamole.md @@ -1,2 +1,5 @@ # Ingredients -+- avocado -+- lemon -+- salt ++* avocado ++* lemon ++* salt # Instructions ``` @@ -358,9 +358,9 @@ $ cat guacamole.md ```output # Ingredients -- avocado -- lime -- salt +* avocado +* lime +* salt # Instructions ``` @@ -375,10 +375,10 @@ index 315bf3a..b36abfd 100644 +++ b/guacamole.md @@ -1,5 +1,5 @@ # Ingredients - - avocado --- lemon -+- lime - - salt + * avocado +-* lemon ++* lime + * salt # Instructions ``` @@ -411,10 +411,10 @@ index 315bf3a..b36abfd 100644 +++ b/guacamole.md @@ -1,5 +1,5 @@ # Ingredients - - avocado --- lemon -+- lime - - salt + * avocado +-* lemon ++* lime + * salt # Instructions ``` @@ -695,9 +695,9 @@ $ cat guacamole.md ```output # Ingredients -- avocado (1.35) -- lime (0.64) -- salt (2) +* avocado (1.35) +* lime (0.64) +* salt (2) ``` ```bash @@ -707,9 +707,9 @@ $ cat groceries.md ```output # Market A -- avocado: 1.35 per unit. -- lime: 0.64 per unit -- salt: 2 per kg +* avocado: 1.35 per unit. +* lime: 0.64 per unit +* salt: 2 per kg ``` Now you can add both files to the staging area. We can do that in one line: diff --git a/episodes/05-history.md b/episodes/05-history.md index 9a13c681e8..6958f8987f 100644 --- a/episodes/05-history.md +++ b/episodes/05-history.md @@ -36,9 +36,9 @@ $ cat guacamole.md ```output # Ingredients -- avocado -- lime -- salt +* avocado +* lime +* salt # Instructions An ill-considered change ``` @@ -55,8 +55,8 @@ index b36abfd..0848c8d 100644 --- a/guacamole.md +++ b/guacamole.md @@ -3,3 +3,4 @@ - - lime - - salt + * lime + * salt # Instructions +An ill-considered change ``` @@ -85,9 +85,9 @@ index df0654a..b36abfd 100644 +++ b/guacamole.md @@ -1,2 +1,5 @@ # Ingredients -+- avocado -+- lime -+- salt ++* avocado ++* lime ++* salt # Instructions ``` @@ -146,9 +146,9 @@ index df0654a..93a3e13 100644 +++ b/guacamole.md @@ -1,2 +1,5 @@ # Ingredients -+- avocado -+- lime -+- salt ++* avocado ++* lime ++* salt # Instructions +An ill-considered change ``` @@ -168,9 +168,9 @@ index df0654a..93a3e13 100644 +++ b/guacamole.md @@ -1,2 +1,5 @@ # Ingredients -+- avocado -+- lime -+- salt ++* avocado ++* lime ++* salt # Instructions +An ill-considered change ``` @@ -209,9 +209,9 @@ $ cat guacamole.md ```output # Ingredients -- avocado -- lime -- salt +* avocado +* lime +* salt # Instructions ``` diff --git a/episodes/08-collab.md b/episodes/08-collab.md index 8b8224638e..6ea646e466 100644 --- a/episodes/08-collab.md +++ b/episodes/08-collab.md @@ -78,10 +78,10 @@ $ cat hummus.md ```output # Ingredients -- chickpeas -- lemon -- olive oil -- salt +* chickpeas +* lemon +* olive oil +* salt ``` ```bash diff --git a/episodes/09-conflict.md b/episodes/09-conflict.md index 547b816777..10538c823a 100644 --- a/episodes/09-conflict.md +++ b/episodes/09-conflict.md @@ -34,9 +34,9 @@ $ cat guacamole.md ```output # Ingredients -- avocado -- lime -- salt +* avocado +* lime +* salt # Instructions ``` @@ -49,11 +49,11 @@ $ cat guacamole.md ```output # Ingredients -- avocado -- lime -- salt +* avocado +* lime +* salt # Instructions -- put one avocado into a bowl. +* put one avocado into a bowl. ``` and then push the change to GitHub: @@ -95,11 +95,11 @@ $ cat guacamole.md ```output # Ingredients -- avocado -- lime -- salt +* avocado +* lime +* salt # Instructions -- peel the avocados +* peel the avocados ``` We can commit the change locally: @@ -208,14 +208,14 @@ $ cat guacamole.md ```output # Ingredients -- avocado -- lime -- salt +* avocado +* lime +* salt # Instructions <<<<<<< HEAD -- peel the avocados +* peel the avocados ======= -- put one avocado into a bowl. +* put one avocado into a bowl. >>>>>>> dabb4c8c450e8475aee9b14b4383acc99f42af1d ``` @@ -238,11 +238,11 @@ $ cat guacamole.md ```output # Ingredients -- avocado -- lime -- salt +* avocado +* lime +* salt # Instructions -- peel the avocados and put them into a bowl. +* peel the avocados and put them into a bowl. ``` To finish merging, @@ -322,11 +322,11 @@ $ cat guacamole.md ```output # Ingredients -- avocado -- lime -- salt +* avocado +* lime +* salt # Instructions -- peel the avocados and put them into a bowl. +* peel the avocados and put them into a bowl. ``` We don't need to merge again because Git knows someone has already done that. From 50338c8dfe72cfee0a6180f6f33bde6dbc7f3953 Mon Sep 17 00:00:00 2001 From: David Perez-Suarez Date: Wed, 14 Aug 2024 16:37:49 +0100 Subject: [PATCH 07/13] Modifies examples to include a single heading This is done to have files with a single heading as accessibility recommendations. A title is introduced (recipe title) and the ingredients and instructions are set as 2nd level headings. --- episodes/04-changes.md | 44 ++++++++++++++++++++++---------------- episodes/05-history.md | 47 +++++++++++++++++++++++------------------ episodes/08-collab.md | 5 +++-- episodes/09-conflict.md | 30 +++++++++++++++----------- 4 files changed, 74 insertions(+), 52 deletions(-) diff --git a/episodes/04-changes.md b/episodes/04-changes.md index 3cb39912a1..de7b818282 100644 --- a/episodes/04-changes.md +++ b/episodes/04-changes.md @@ -40,8 +40,9 @@ $ nano guacamole.md Type the text below into the `guacamole.md` file: ```output -# Ingredients -# Instructions +# Guacamole +## Ingredients +## Instructions ``` Let's first verify that the file was properly created by running the list command (`ls`): @@ -61,8 +62,9 @@ $ cat guacamole.md ``` ```output -# Ingredients -# Instructions +# Guacamole +## Ingredients +## Instructions ``` If we check the status of our project again, @@ -201,11 +203,12 @@ $ cat guacamole.md ``` ```output -# Ingredients +# Guacamole +## Ingredients - avocado - lemon - salt -# Instructions +## Instructions ``` When we run `git status` now, @@ -246,12 +249,13 @@ diff --git a/guacamole.md b/guacamole.md index df0654a..315bf3a 100644 --- a/guacamole.md +++ b/guacamole.md -@@ -1,2 +1,5 @@ - # Ingredients +@@ -1,3 +1,6 @@ + # Guacamole + ## Ingredients +- avocado +- lemon +- salt - # Instructions + ## Instructions ``` The output is cryptic because @@ -357,11 +361,12 @@ $ cat guacamole.md ``` ```output -# Ingredients +# Guacamole +## Ingredients - avocado - lime - salt -# Instructions +## Instructions ``` ```bash @@ -373,13 +378,14 @@ diff --git a/guacamole.md b/guacamole.md index 315bf3a..b36abfd 100644 --- a/guacamole.md +++ b/guacamole.md -@@ -1,5 +1,5 @@ - # Ingredients +@@ -1,6 +1,6 @@ + # Guacamole + ## Ingredients - avocado -- lemon +- lime - salt - # Instructions + ## Instructions ``` So far, so good: @@ -409,13 +415,14 @@ diff --git a/guacamole.md b/guacamole.md index 315bf3a..b36abfd 100644 --- a/guacamole.md +++ b/guacamole.md -@@ -1,5 +1,5 @@ - # Ingredients +@@ -1,6 +1,6 @@ + # Guacamole + ## Ingredients - avocado -- lemon +- lime - salt - # Instructions + ## Instructions ``` it shows us the difference between @@ -694,7 +701,8 @@ $ cat guacamole.md ``` ```output -# Ingredients +# Guacamole +## Ingredients - avocado (1.35) - lime (0.64) - salt (2) diff --git a/episodes/05-history.md b/episodes/05-history.md index 9a13c681e8..0c7fef8190 100644 --- a/episodes/05-history.md +++ b/episodes/05-history.md @@ -35,11 +35,12 @@ $ cat guacamole.md ``` ```output -# Ingredients +# Guacamole +## Ingredients - avocado - lime - salt -# Instructions +## Instructions An ill-considered change ``` @@ -54,10 +55,10 @@ diff --git a/guacamole.md b/guacamole.md index b36abfd..0848c8d 100644 --- a/guacamole.md +++ b/guacamole.md -@@ -3,3 +3,4 @@ +@@ -4,3 +4,4 @@ - lime - salt - # Instructions + ## Instructions +An ill-considered change ``` @@ -83,12 +84,13 @@ diff --git a/guacamole.md b/guacamole.md index df0654a..b36abfd 100644 --- a/guacamole.md +++ b/guacamole.md -@@ -1,2 +1,5 @@ - # Ingredients +@@ -1,3 +1,6 @@ + # Guacamole + ## Ingredients +- avocado +- lime +- salt - # Instructions + ## Instructions ``` We could also use `git show` which shows us what changes we made at an older commit as @@ -111,9 +113,10 @@ new file mode 100644 index 0000000..df0654a --- /dev/null +++ b/guacamole.md -@@ -0,0 +1,2 @@ -+# Ingredients -+# Instructions +@@ -0,0 +1,3 @@ ++# Guacamole ++## Ingredients ++## Instructions ``` In this way, @@ -144,12 +147,13 @@ diff --git a/guacamole.md b/guacamole.md index df0654a..93a3e13 100644 --- a/guacamole.md +++ b/guacamole.md -@@ -1,2 +1,5 @@ - # Ingredients +@@ -1,3 +1,7 @@ + # Guacamole + ## Ingredients +- avocado +- lime +- salt - # Instructions + ## Instructions +An ill-considered change ``` @@ -166,12 +170,13 @@ diff --git a/guacamole.md b/guacamole.md index df0654a..93a3e13 100644 --- a/guacamole.md +++ b/guacamole.md -@@ -1,2 +1,5 @@ - # Ingredients +@@ -1,3 +1,7 @@ + # Gucamole + ## Ingredients +- avocado +- lime +- salt - # Instructions + ## Instructions +An ill-considered change ``` @@ -208,11 +213,12 @@ $ cat guacamole.md ``` ```output -# Ingredients +# Guacamole +## Ingredients - avocado - lime - salt -# Instructions +## Instructions ``` As you might guess from its name, @@ -232,8 +238,9 @@ $ cat guacamole.md ``` ```output -# Ingredients -# Instructions +# Guacamole +## Ingredients +## Instructions ``` ```bash diff --git a/episodes/08-collab.md b/episodes/08-collab.md index 8b8224638e..b723c827db 100644 --- a/episodes/08-collab.md +++ b/episodes/08-collab.md @@ -77,7 +77,8 @@ $ cat hummus.md ``` ```output -# Ingredients +# Hummus +## Ingredients - chickpeas - lemon - olive oil @@ -90,7 +91,7 @@ $ git commit -m "Add ingredients for hummus" ``` ```output - 1 file changed, 5 insertion(+) + 1 file changed, 6 insertion(+) create mode 100644 hummus.md ``` diff --git a/episodes/09-conflict.md b/episodes/09-conflict.md index 547b816777..7da313d1c7 100644 --- a/episodes/09-conflict.md +++ b/episodes/09-conflict.md @@ -33,11 +33,12 @@ $ cat guacamole.md ``` ```output -# Ingredients +# Guacamole +## Ingredients - avocado - lime - salt -# Instructions +## Instructions ``` Let's add a line to the collaborator's copy only: @@ -48,11 +49,12 @@ $ cat guacamole.md ``` ```output -# Ingredients +# Guacamole +## Ingredients - avocado - lime - salt -# Instructions +## Instructions - put one avocado into a bowl. ``` @@ -94,11 +96,12 @@ $ cat guacamole.md ``` ```output -# Ingredients +# Guacamole +## Ingredients - avocado - lime - salt -# Instructions +## Instructions - peel the avocados ``` @@ -207,11 +210,12 @@ $ cat guacamole.md ``` ```output -# Ingredients +# Guacamole +## Ingredients - avocado - lime - salt -# Instructions +## Instructions <<<<<<< HEAD - peel the avocados ======= @@ -237,11 +241,12 @@ $ cat guacamole.md ``` ```output -# Ingredients +# Guacamole +## Ingredients - avocado - lime - salt -# Instructions +## Instructions - peel the avocados and put them into a bowl. ``` @@ -321,11 +326,12 @@ $ cat guacamole.md ``` ```output -# Ingredients +# Guacamole +## Ingredients - avocado - lime - salt -# Instructions +## Instructions - peel the avocados and put them into a bowl. ``` From 7de60cb233a6fb1869a050f94b5185ebbb69f93c Mon Sep 17 00:00:00 2001 From: Martino Sorbaro Date: Wed, 14 Aug 2024 18:24:11 +0200 Subject: [PATCH 08/13] Use present tense and capital letter in commit messages Co-authored-by: Nicola Soranzo --- learners/discuss.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/learners/discuss.md b/learners/discuss.md index c1da4a0baf..6a261418ba 100644 --- a/learners/discuss.md +++ b/learners/discuss.md @@ -229,7 +229,7 @@ Now add to the repository like you have learned earlier: ```bash $ git add invisible.md -$ git commit -m 'adding secret sauce' +$ git commit -m 'Add secret sauce' $ git status ``` @@ -261,7 +261,7 @@ in the new commit. The previous commit will still have the file, if you were to retrieve that specific commit. ```bash -$ git commit -m 'Removing info on Invisible ink. It is not an edible sauce!' +$ git commit -m 'Remove info on Invisible ink. It is not an edible sauce!' ``` ## Removing a File with Unix @@ -274,7 +274,7 @@ commit it again. ```bash $ echo "This is anoher way to make invisible ink" > secret.md $ git add secret.md -$ git commit -m 'adding invisible ink again' +$ git commit -m 'Add invisible ink again' ``` Now we remove the file with Unix `rm`: @@ -318,7 +318,7 @@ The change that was made in Unix has now been staged and needs to be committed. ```bash -$ git commit -m 'Removing info on invisible ink, again!' +$ git commit -m 'Remove info on invisible ink, again!' ``` ## Renaming a File @@ -335,7 +335,7 @@ Add it to the repository: ```bash $ git add whitesauce.md -$ git commit -m 'Adding white sauce recipe' +$ git commit -m 'Add white sauce recipe' ``` We all know that white sauce has a more sophisticated name. @@ -358,7 +358,7 @@ Changes to be committed: The final step is commit our change to the repository: ```bash -$ git commit -m 'Using the French name for the whitesauce' +$ git commit -m 'Use the French name for the whitesauce' ``` ## Renaming a File with Unix @@ -372,7 +372,7 @@ this time with Unix `mv`. First, we need to recreate the ```bash $ echo "Very fun recipe to do" > whitesauce.md $ git add whitesauce.md -$ git commit -m 'Adding white sauce recipe' +$ git commit -m 'Add white sauce recipe' ``` Let us rename the file and see what Git can figured out by itself: @@ -423,7 +423,7 @@ disappeared - it has simply been renamed. The final step, as before, is to commit our change to the repository: ```bash -$ git commit -m 'Using the French name for the whitesauce' +$ git commit -m 'Use the French name for the whitesauce' ``` ## Further .gitignore concepts From 5f03c1fc433840c9949f1932f0bdf2e6b079b66b Mon Sep 17 00:00:00 2001 From: Martino Sorbaro Date: Wed, 14 Aug 2024 18:29:39 +0200 Subject: [PATCH 09/13] Further capitalization suggestions by nsoranzo Co-authored-by: Nicola Soranzo --- episodes/05-history.md | 4 ++-- episodes/09-conflict.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/episodes/05-history.md b/episodes/05-history.md index 9a13c681e8..9df3f20935 100644 --- a/episodes/05-history.md +++ b/episodes/05-history.md @@ -447,7 +447,7 @@ $ cd recipes $ echo "I like tomatos, therefore I like ketchup" > ketchup.md $ git add ketchup.md $ echo "ketchup enchances pasta dishes" > ketchup.md -$ git commit -m "my opinions about the red sauce" +$ git commit -m "My opinions about the red sauce" $ git checkout HEAD ketchup.md $ cat ketchup.md # this will print the content of ketchup.md on screen ``` @@ -476,7 +476,7 @@ The changes to the file from the second `echo` command are only applied to the w The command `git add ketchup.md` places the current version of `ketchup.md` into the staging area. not the version in the staging area. -So, when `git commit -m "my opinions about the red sauce"` is executed, +So, when `git commit -m "My opinions about the red sauce"` is executed, the version of `ketchup.md` committed to the repository is the one from the staging area and has only one line. diff --git a/episodes/09-conflict.md b/episodes/09-conflict.md index 547b816777..c6d093db4c 100644 --- a/episodes/09-conflict.md +++ b/episodes/09-conflict.md @@ -159,9 +159,9 @@ Automatic merge failed; fix conflicts and then commit the result. ::::::::::::::::::::::::::::::::::::::::: callout -## You may need to tell git what to do +## You may need to tell Git what to do -If you see the below in your output, git is asking what it should do. +If you see the below in your output, Git is asking what it should do. ```output hint: You have divergent branches and need to specify how to reconcile them. @@ -178,7 +178,7 @@ hint: or --ff-only on the command line to override the configured default per hint: invocation. ``` -In newer versions of git it gives you the option of specifying different +In newer versions of Git it gives you the option of specifying different behaviours when a pull would merge divergent branches. In our case we want 'the default strategy'. To use this strategy run the following command to select it as the default thing git should do. From 7e18fdf40677643aa68ab84fdcda831b1c2b1ea8 Mon Sep 17 00:00:00 2001 From: Martino Sorbaro Date: Wed, 14 Aug 2024 18:38:58 +0200 Subject: [PATCH 10/13] Change tomatos to tomatoes Co-authored-by: Toby Hodges --- episodes/05-history.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/episodes/05-history.md b/episodes/05-history.md index 9df3f20935..609807d7ef 100644 --- a/episodes/05-history.md +++ b/episodes/05-history.md @@ -444,7 +444,7 @@ What is the output of the last command in ```bash $ cd recipes -$ echo "I like tomatos, therefore I like ketchup" > ketchup.md +$ echo "I like tomatoes, therefore I like ketchup" > ketchup.md $ git add ketchup.md $ echo "ketchup enchances pasta dishes" > ketchup.md $ git commit -m "My opinions about the red sauce" @@ -456,10 +456,10 @@ $ cat ketchup.md # this will print the content of ketchup.md on screen ketchup enchances pasta dishes ``` 2. ```output - I like tomatos, therefore I like ketchup + I like tomatoes, therefore I like ketchup ``` 3. ```output - I like tomatos, therefore I like ketchup + I like tomatoes, therefore I like ketchup ketchup enchances pasta dishes ``` 4. ```output @@ -487,7 +487,7 @@ replaces the working copy with the most recently committed version of `ketchup.m So, `cat ketchup.md` will output ```output -I like tomatos, therefore I like ketchup +I like tomatoes, therefore I like ketchup ``` ::::::::::::::::::::::::: From eceba16331114f203679d4630bb6857539b77261 Mon Sep 17 00:00:00 2001 From: Martino Sorbaro Date: Wed, 14 Aug 2024 18:41:02 +0200 Subject: [PATCH 11/13] Use output syntax highlighting for git status Co-authored-by: Toby Hodges --- episodes/05-history.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/episodes/05-history.md b/episodes/05-history.md index 609807d7ef..76d94089ad 100644 --- a/episodes/05-history.md +++ b/episodes/05-history.md @@ -320,7 +320,7 @@ here's how Git works in cartoon form: If you read the output of `git status` carefully, you'll see that it includes this hint: -```bash +```output (use "git checkout -- ..." to discard changes in working directory) ``` From f6cf2f9c06664d40bdab13e20347c732784da88f Mon Sep 17 00:00:00 2001 From: Martino Sorbaro Date: Thu, 15 Aug 2024 16:35:57 +0200 Subject: [PATCH 12/13] remove reference to advanced ssh material that was mistakenly reintroduced --- episodes/07-github.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/episodes/07-github.md b/episodes/07-github.md index 048c4552da..87310e8fcf 100644 --- a/episodes/07-github.md +++ b/episodes/07-github.md @@ -90,8 +90,7 @@ Click on the 'SSH' link to change the [protocol](../learners/reference.md#protoc We use SSH here because, while it requires some additional configuration, it is a security protocol widely used by many applications. The steps below describe SSH at a -minimum level for GitHub. A supplemental episode to this lesson discusses advanced setup -and concepts of SSH and key pairs, and other material supplemental to git related SSH. +minimum level for GitHub. :::::::::::::::::::::::::::::::::::::::::::::::::: From 11f83167692f3495e9b65c4306f05118ad324613 Mon Sep 17 00:00:00 2001 From: Martino Sorbaro Date: Wed, 18 Sep 2024 14:42:04 +0200 Subject: [PATCH 13/13] Update learners/discuss.md Co-authored-by: James Foster <38274066+jd-foster@users.noreply.github.com> --- learners/discuss.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/learners/discuss.md b/learners/discuss.md index 6a261418ba..40064be263 100644 --- a/learners/discuss.md +++ b/learners/discuss.md @@ -272,7 +272,7 @@ Git is smart enough to notice the missing file. Let us recreate the file and commit it again. ```bash -$ echo "This is anoher way to make invisible ink" > secret.md +$ echo "This is another way to make invisible ink" > secret.md $ git add secret.md $ git commit -m 'Add invisible ink again' ```