@@ -20,32 +20,17 @@ exercises: 0
20
20
Once Git is configured,
21
21
we can start using it.
22
22
23
- We will continue with the story of Wolfman and Dracula who are investigating if it
24
- is possible to send a planetary lander to Mars.
25
-
26
- ![ ] ( fig/motivatingexample.png ) {alt='motivatingexample'}
27
- [ Werewolf vs dracula] ( https://www.deviantart.com/b-maze/art/Werewolf-vs-Dracula-124893530 )
28
- by [ b-maze] ( https://www.deviantart.com/b-maze ) / [ Deviant Art] ( https://www.deviantart.com/ ) .
29
- [ Mars] ( https://en.wikipedia.org/wiki/File:OSIRIS_Mars_true_color.jpg ) by European Space Agency /
30
- [ CC-BY-SA 3.0 IGO] ( https://creativecommons.org/licenses/by/3.0/deed.en ) .
31
- [ Pluto] ( https://commons.wikimedia.org/wiki/File:PIA19873-Pluto-NewHorizons-FlyingPastImage-20150714-transparent.png ) /
32
- Courtesy NASA/JPL-Caltech.
33
- [ Mummy] ( https://commons.wikimedia.org/wiki/File:Mummy_icon_-_Noun_Project_4070.svg )
34
- © Gilad Fried / [ The Noun Project] ( https://thenounproject.com/ ) /
35
- [ CC BY 3.0] ( https://creativecommons.org/licenses/by/3.0/deed.en ) .
36
- [ Moon] ( https://commons.wikimedia.org/wiki/File:Lune_ico.png )
37
- © Luc Viatour / [ https://lucnix.be ] ( https://lucnix.be/ ) /
38
- [ CC BY-SA 3.0] ( https://creativecommons.org/licenses/by-sa/3.0/deed.en ) .
23
+ We will help Alfredo with his new project, create a repository with all his recipes.
39
24
40
25
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:
41
26
42
27
``` bash
43
28
$ cd ~ /Desktop
44
- $ mkdir planets
45
- $ cd planets
29
+ $ mkdir recipes
30
+ $ cd recipes
46
31
```
47
32
48
- Then we tell Git to make ` planets ` a [ repository] ( ../learners/reference.md#repository )
33
+ Then we tell Git to make ` recipes ` a [ repository] ( ../learners/reference.md#repository )
49
34
\- - a place where Git can store versions of our files:
50
35
51
36
``` bash
@@ -54,9 +39,9 @@ $ git init
54
39
55
40
It is important to note that ` git init ` will create a repository that
56
41
can include subdirectories and their files---there is no need to create
57
- separate repositories nested within the ` planets ` repository, whether
42
+ separate repositories nested within the ` recipes ` repository, whether
58
43
subdirectories are present from the beginning or added later. Also, note
59
- that the creation of the ` planets ` directory and its initialization as a
44
+ that the creation of the ` recipes ` directory and its initialization as a
60
45
repository are completely separate processes.
61
46
62
47
If we use ` ls ` to show the directory's contents,
67
52
```
68
53
69
54
But if we add the ` -a ` flag to show everything,
70
- we can see that Git has created a hidden directory within ` planets ` called ` .git ` :
55
+ we can see that Git has created a hidden directory within ` recipes ` called ` .git ` :
71
56
72
57
``` bash
73
58
$ ls -a
@@ -117,33 +102,33 @@ wording of the output might be slightly different.
117
102
118
103
## Places to Create Git Repositories
119
104
120
- Along with tracking information about planets (the project we have already created),
121
- Dracula would also like to track information about moons .
122
- Despite Wolfman 's concerns, Dracula creates a ` moons ` project inside his ` planets `
105
+ Along with tracking information about recipes (the project we have already created),
106
+ Alfredo would also like to track information about cocktails .
107
+ Despite Jimmy 's concerns, Alfredo creates a ` cocktails ` project inside his ` recipes `
123
108
project with the following sequence of commands:
124
109
125
110
``` bash
126
- $ cd ~ /Desktop # return to Desktop directory
127
- $ cd planets # go into planets directory, which is already a Git repository
128
- $ ls -a # ensure the .git subdirectory is still present in the planets directory
129
- $ mkdir moons # make a subdirectory planets/moons
130
- $ cd moons # go into moons subdirectory
131
- $ git init # make the moons subdirectory a Git repository
132
- $ ls -a # ensure the .git subdirectory is present indicating we have created a new Git repository
111
+ $ cd ~ /Desktop # return to Desktop directory
112
+ $ cd recipes # go into recipes directory, which is already a Git repository
113
+ $ ls -a # ensure the .git subdirectory is still present in the recipes directory
114
+ $ mkdir cocktails # make a sub-directory recipes/cocktails
115
+ $ cd cocktails # go into cocktails subdirectory
116
+ $ git init # make the cocktails subdirectory a Git repository
117
+ $ ls -a # ensure the .git subdirectory is present indicating we have created a new Git repository
133
118
```
134
119
135
- Is the ` git init ` command, run inside the ` moons ` subdirectory, required for
136
- tracking files stored in the ` moons ` subdirectory?
120
+ Is the ` git init ` command, run inside the ` cocktails ` subdirectory, required for
121
+ tracking files stored in the ` cocktails ` subdirectory?
137
122
138
123
::::::::::::::: solution
139
124
140
125
## Solution
141
126
142
- No. Dracula does not need to make the ` moons ` subdirectory a Git repository
143
- because the ` planets ` repository can track any files, sub-directories, and
144
- subdirectory files under the ` planets ` directory. Thus, in order to track
145
- all information about moons, Dracula only needed to add the ` moons ` subdirectory
146
- to the ` planets ` directory.
127
+ No. Alfredo does not need to make the ` cocktails ` subdirectory a Git repository
128
+ because the ` recipes ` repository will track all files, sub-directories, and
129
+ subdirectory files under the ` recipes ` directory. Thus, in order to track
130
+ all information about cocktails, Alfredo only needed to add the ` cocktails ` subdirectory
131
+ to the ` recipes ` directory.
147
132
148
133
Additionally, Git repositories can interfere with each other if they are "nested":
149
134
the outer repository will try to version-control
@@ -165,9 +150,9 @@ fatal: Not a git repository (or any of the parent directories): .git
165
150
166
151
## Correcting ` git init ` Mistakes
167
152
168
- Wolfman explains to Dracula how a nested repository is redundant and may cause confusion
169
- down the road. Dracula would like to remove the nested repository. How can Dracula undo
170
- his last ` git init ` in the ` moons ` subdirectory?
153
+ Jimmy explains to Alfredo how a nested repository is redundant and may cause confusion
154
+ down the road. Alfredo would like to remove the nested repository. How can Alfredo undo
155
+ his last ` git init ` in the ` cocktails ` subdirectory?
171
156
172
157
::::::::::::::: solution
173
158
@@ -190,11 +175,11 @@ becomes another change that we will need to track, as we will see in the next ep
190
175
### Solution
191
176
192
177
Git keeps all of its files in the ` .git ` directory.
193
- To recover from this little mistake, Dracula can just remove the ` .git `
194
- folder in the moons subdirectory by running the following command from inside the ` planets ` directory:
178
+ To recover from this little mistake, Alfredo can just remove the ` .git `
179
+ folder in the cocktails subdirectory by running the following command from inside the ` recipes ` directory:
195
180
196
181
``` bash
197
- $ rm -rf moons /.git
182
+ $ rm -rf cocktails /.git
198
183
```
199
184
200
185
But be careful! Running this command in the wrong directory will remove
0 commit comments