Skip to content

Commit 6e53b6f

Browse files
committed
use language-bash CSS class
1 parent eb76373 commit 6e53b6f

File tree

4 files changed

+94
-94
lines changed

4 files changed

+94
-94
lines changed

_episodes/02-getting-started.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ keypoints:
1818

1919
### Using Git
2020

21-
One of the main barriers to getting started with git is the language. Although some of the language used in git is
22-
fairly self-explanatory, other terms are not so clear. The best way to get to learn the language - which consists of a
23-
number of verbs such as `add`, `commit` and `push` (preceded by the word 'git') - is by using it, which is what we will be doing during this
24-
lesson. These commands will be explained as we proceed from setting up a new version-controlled project to publishing
21+
One of the main barriers to getting started with git is the language. Although some of the language used in git is
22+
fairly self-explanatory, other terms are not so clear. The best way to get to learn the language - which consists of a
23+
number of verbs such as `add`, `commit` and `push` (preceded by the word 'git') - is by using it, which is what we will be doing during this
24+
lesson. These commands will be explained as we proceed from setting up a new version-controlled project to publishing
2525
our own website.
2626

2727

2828
### Creating a repository
2929

30-
A Git **repository** is a data structure used to track changes to a set of project files over time. Repositories are
31-
stored within the same directory as these project files, in a hidden directory called `.git`. We can create a new git
32-
repository either by using [GitHub's web interface](https://github.com/new), or via the command line. Let's use the command line to create a git
30+
A Git **repository** is a data structure used to track changes to a set of project files over time. Repositories are
31+
stored within the same directory as these project files, in a hidden directory called `.git`. We can create a new git
32+
repository either by using [GitHub's web interface](https://github.com/new), or via the command line. Let's use the command line to create a git
3333
repository for the experiments that we're going to do today.
3434

3535
First, we will create a new directory for our project and enter that directory.
@@ -39,29 +39,29 @@ First, we will create a new directory for our project and enter that directory.
3939
$ mkdir hello-world
4040
$ cd hello-world
4141
~~~
42-
{: .bash}
42+
{: .language-bash }
4343

44-
We will now create an empty git repository to track changes to our project. To do this we will use the git **init** command,
44+
We will now create an empty git repository to track changes to our project. To do this we will use the git **init** command,
4545
which is simply short for *initialise*.
4646

4747
~~~
4848
$ git init
4949
~~~
50-
{: .bash}
50+
{: .language-bash }
5151
~~~
5252
Initialized empty Git repository in <your file path>/hello-world/.git/
5353
~~~
5454
{: .output}
5555

5656

57-
The `hello-world` directory is now a git repository.
57+
The `hello-world` directory is now a git repository.
5858

59-
If we run the `ls` command now (`ls` lists the content of the `hello-world`
60-
directory), the repository might seem empty; however, adding the `-a` flag
61-
for all files via `ls -a` will show all hidden files, which in this case
59+
If we run the `ls` command now (`ls` lists the content of the `hello-world`
60+
directory), the repository might seem empty; however, adding the `-a` flag
61+
for all files via `ls -a` will show all hidden files, which in this case
6262
includes the new hidden directory `.git`. Flags can simply be thought of as command line options that can be added to shell commands.
6363

64-
Note that whenever we use git via the command line, we need to preface each command (or verb) with `git`, so that the computer knows
64+
Note that whenever we use git via the command line, we need to preface each command (or verb) with `git`, so that the computer knows
6565
we are trying to get git to do something, rather than some other program.
6666

6767
### Displaying the current project's status
@@ -71,30 +71,30 @@ We can run the `git status` command to display the current state of a project. L
7171
~~~
7272
$ git status
7373
~~~
74-
{: .bash}
74+
{: .language-bash }
7575
~~~
7676
On branch master
7777
No commits yet
7878
nothing to commit (create/copy files and use "git add" to track)
7979
~~~
8080
{: .output}
8181

82-
The output tells us that we are on the master branch (more on this later) and that we have nothing to commit (no
82+
The output tells us that we are on the master branch (more on this later) and that we have nothing to commit (no
8383
unsaved changes).
8484

8585

8686
### Adding and committing
8787

88-
We will now create and save our first project file. This is a two-stage process. First, we **add** any files for which
89-
we want to save the changes to a staging area, then we **commit** those changes to the repository. This two-stage
88+
We will now create and save our first project file. This is a two-stage process. First, we **add** any files for which
89+
we want to save the changes to a staging area, then we **commit** those changes to the repository. This two-stage
9090
process gives us fine-grained control over what should and should not be included in a particular commit.
9191

9292
Let's create a new file using the `touch` command, which is a quick way to create an empty file.
9393

9494
~~~
9595
$ touch index.md
9696
~~~
97-
{: .bash}
97+
{: .language-bash }
9898

9999
The `.md` extension above signifies that we have chosen to use the Markdown format, a lightweight markup language with plain text formatting syntax. We will explore Markdown a bit later.
100100

@@ -103,7 +103,7 @@ Let's check the status of our project again.
103103
~~~
104104
$ git status
105105
~~~
106-
{: .bash}
106+
{: .language-bash }
107107
~~~
108108
On branch master
109109
No commits yet
@@ -116,21 +116,21 @@ nothing added to commit but untracked files present (use "git add" to track)
116116
~~~
117117
{: .output}
118118

119-
This status is telling us that git has noticed a new file in our directory that we are not yet tracking. With colourised
120-
output, the filename will appear in red. To change this, and to tell Git we want to track any changes we make to
119+
This status is telling us that git has noticed a new file in our directory that we are not yet tracking. With colourised
120+
output, the filename will appear in red. To change this, and to tell Git we want to track any changes we make to
121121
index.md, we use `git add`.
122122

123123
~~~
124124
$ git add index.md
125125
~~~
126-
{: .bash}
126+
{: .language-bash }
127127

128128
This adds our Markdown file to the **staging area** (the area where git checks for file changes). To confirm this we want to use `git status` again.
129129

130130
~~~
131131
$ git status
132132
~~~
133-
{: .bash}
133+
{: .language-bash }
134134
~~~
135135
On branch master
136136
@@ -153,7 +153,7 @@ has spotted the changes.
153153
~~~
154154
$ git status
155155
~~~
156-
{: .bash}
156+
{: .language-bash }
157157
~~~
158158
On branch master
159159
@@ -172,32 +172,32 @@ Changes not staged for commit:
172172
~~~
173173
{: .output}
174174

175-
This lets us know that git has indeed spotted the changes to our file, but that it hasn't yet staged them, so let's add
175+
This lets us know that git has indeed spotted the changes to our file, but that it hasn't yet staged them, so let's add
176176
the new version of the file to the staging area.
177177

178178
~~~
179179
$ git add index.md
180180
~~~
181-
{: .bash}
181+
{: .language-bash }
182182

183-
Now we are ready to **commit** our first changes.
184-
Commit is similar to 'saving' a file to Git.
183+
Now we are ready to **commit** our first changes.
184+
Commit is similar to 'saving' a file to Git.
185185
However, compared to saving, a commit provides a lot more information about the changes we have made,
186186
and this information will remain visible to us later.
187187

188188

189189
~~~
190190
$ git commit -m 'Add index.md'
191191
~~~
192-
{: .bash}
192+
{: .language-bash }
193193
~~~
194194
[master (root-commit) e9e8fd3] Add index.md
195195
1 file changed, 1 insertion(+)
196196
create mode 100644 index.md
197197
~~~
198198
{: .output}
199199

200-
We can see that one file has changed and that we made one insertion, which was a line with the text '#Hello, world!'.
200+
We can see that one file has changed and that we made one insertion, which was a line with the text '#Hello, world!'.
201201
We can
202202
also see the commit message 'Add index.md', which we added by using the `-m` flag after `git commit`.
203203
The commit message is used to record a short, descriptive, and specific summary of what we did to help us remember later on without having to look at the actual changes.
@@ -229,6 +229,6 @@ along with metadata about who made the commit and at what time.
229229

230230
![The Git Staging Area](../fig/git-staging-area.svg)
231231

232-
At the moment, our changes are only recorded locally, on our computer. If we wanted to
232+
At the moment, our changes are only recorded locally, on our computer. If we wanted to
233233
work collaboratively with someone else they would have no way of seeing what we've done.
234234
We will fix that in the next episode by using GitHub to share our work.

_episodes/03-sharing.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ to the GitHub repository:
7373
~~~
7474
$ git remote add origin https://github.com/some-librarian/hello-world.git
7575
~~~
76-
{: .bash}
76+
{: .language-bash }
7777

7878
where `some-librarian` should be replaced with your own username.
7979

@@ -88,7 +88,7 @@ We can check that it is set up correctly with the command:
8888
~~~
8989
$ git remote -v
9090
~~~
91-
{: .bash}
91+
{: .language-bash }
9292
~~~
9393
origin https://github.com/<your_github_username>/hello-world (fetch)
9494
origin https://github.com/<your_github_username>/hello-world (push)
@@ -105,7 +105,7 @@ will have to "push" our local changes to the GitHub repository. We do this using
105105
~~~
106106
$ git push -u origin master
107107
~~~
108-
{: .bash}
108+
{: .language-bash }
109109
~~~
110110
Counting objects: 3, done.
111111
Writing objects: 100% (3/3), 226 bytes | 0 bytes/s, done.
@@ -118,40 +118,40 @@ Branch master set up to track remote branch master from origin.
118118

119119
The nickname of our remote repository is "origin" and the default local branch name is "master".
120120
The `-u` flag tells git to remember the parameters, so that next time we can simply run `git push`
121-
and Git will know what to do.
121+
and Git will know what to do.
122122

123-
Pushing our local changes to the Github repository is sometimes referred to as "pushing changes `upstream` to Github".
124-
The word `upstream` here comes from the git flag we used earlier in the command `git push -u origin master`.
125-
The flag `-u` refers to `-set-upstream`, so when we say pushing changes upstream, it refers to the remote repository.
123+
Pushing our local changes to the Github repository is sometimes referred to as "pushing changes `upstream` to Github".
124+
The word `upstream` here comes from the git flag we used earlier in the command `git push -u origin master`.
125+
The flag `-u` refers to `-set-upstream`, so when we say pushing changes upstream, it refers to the remote repository.
126126

127127
You may be prompted to enter your GitHub username and password to complete the command.
128128

129-
When we do a `git push`, we will see Git 'pushing' changes upstream to GitHub. Because our file is very small, this
130-
won't take long but if we had made a lot of changes or were adding a very large repository, we might have to wait a
131-
little longer. We can check where we're at with `git status`.
129+
When we do a `git push`, we will see Git 'pushing' changes upstream to GitHub. Because our file is very small, this
130+
won't take long but if we had made a lot of changes or were adding a very large repository, we might have to wait a
131+
little longer. We can check where we're at with `git status`.
132132

133133
~~~
134134
$ git status
135135
~~~
136-
{: .bash}
136+
{: .language-bash }
137137
~~~
138138
On branch master
139139
Your branch is up-to-date with 'origin/master'.
140140
nothing to commit, working tree clean
141141
~~~
142142
{: .output}
143143

144-
This output lets us know where we are working (the master branch). We can also see that we have no changes to commit
144+
This output lets us know where we are working (the master branch). We can also see that we have no changes to commit
145145
and everything is in order.
146146

147-
We can use the `git diff` command to see changes we have made before making a commit. Open index.md with any text
147+
We can use the `git diff` command to see changes we have made before making a commit. Open index.md with any text
148148
editor and enter some text on a new line, for instance "A new line" or something else.
149149
We will then use `git diff` to see the changes we made:
150150

151151
~~~
152152
$ git diff
153153
~~~
154-
{: .bash}
154+
{: .language-bash }
155155
~~~
156156
diff --git a/index.md b/index.md
157157
index aed0629..989787e 100644
@@ -168,12 +168,12 @@ index aed0629..989787e 100644
168168
The command produces lots of information and it can be a bit overwhelming at first,
169169
but let's go through some key information here:
170170

171-
1. The first line tells us that Git is producing output similar to the Unix `diff` command, comparing the old and new
171+
1. The first line tells us that Git is producing output similar to the Unix `diff` command, comparing the old and new
172172
versions of the file.
173-
2. The second line tells exactly which versions of the file Git is comparing; `aed0629` and `989787e` are unique
173+
2. The second line tells exactly which versions of the file Git is comparing; `aed0629` and `989787e` are unique
174174
computer-generated identifiers for those versions.
175175
3. The third and fourth lines once again show the name of the file being changed.
176-
4. The remaining lines are the most interesting; they show us the actual differences and the lines on which they occur.
176+
4. The remaining lines are the most interesting; they show us the actual differences and the lines on which they occur.
177177
In particular, the + markers in the first column show where we have added lines.
178178

179179
We can now commit these changes:
@@ -182,16 +182,16 @@ We can now commit these changes:
182182
$ git add index.md
183183
$ git commit -m 'Add another line'
184184
~~~
185-
{: .bash}
185+
{: .language-bash }
186186

187-
If we are very forgetful and have already forgotten what we changes we have made, `git log` allows us to look at what
187+
If we are very forgetful and have already forgotten what we changes we have made, `git log` allows us to look at what
188188
we have been doing with our git repository (in reverse chronological order, with the very latest changes first).
189189

190190

191191
~~~
192192
$ git log
193193
~~~
194-
{: .bash}
194+
{: .language-bash }
195195
~~~
196196
commit 8e2eb9920eaa0bf18a4adfa12474ad58b765fd06
197197
Author: Your Name <your_email>
@@ -207,9 +207,9 @@ Date: Fri Jun 2 18:15:43 2017 +0100
207207
~~~
208208
{: .output}
209209

210-
This shows us the two commits we have made and shows the messages we wrote. It is important to try to use meaningful
211-
commit messages when we make changes. This is especially important when we are working with other people who might not
212-
be able to guess as easily what our short cryptic messages might mean. Note that it is best practice to always write
210+
This shows us the two commits we have made and shows the messages we wrote. It is important to try to use meaningful
211+
commit messages when we make changes. This is especially important when we are working with other people who might not
212+
be able to guess as easily what our short cryptic messages might mean. Note that it is best practice to always write
213213
commit messages in the imperative (e.g. 'Add index.md', rather than 'Adding index.md').
214214

215215
## Pushing changes (again)
@@ -224,8 +224,8 @@ And if you click on `index.md` you will see that it contains the "Hello, world!"
224224
but not the new line we just added.
225225

226226
This is because we haven't yet pushed our local changes to the remote repository.
227-
This might seem like a mistake in design but it is
228-
often useful to make a lot of commits for small changes so you are able to make careful revisions later and you don't
227+
This might seem like a mistake in design but it is
228+
often useful to make a lot of commits for small changes so you are able to make careful revisions later and you don't
229229
necessarily want to push all these changes one by one.
230230

231231
Another benefit of this design is that you can make commits without being connected to internet.
@@ -235,7 +235,7 @@ But let's push our changes now, using the `git push` command:
235235
~~~
236236
$ git push
237237
~~~
238-
{: .bash}
238+
{: .language-bash }
239239
~~~
240240
Counting objects: 3, done.
241241
Writing objects: 100% (3/3), 272 bytes | 0 bytes/s, done.
@@ -250,16 +250,16 @@ And let's check on GitHub that we now have 2 commits there.
250250
## Pulling changes
251251

252252
When working with others, or when we're making our own changes from different machines, we need a way of pulling those
253-
remote changes back into our local copy. For now, we can see how this works by making a change on the GitHub website and
253+
remote changes back into our local copy. For now, we can see how this works by making a change on the GitHub website and
254254
then 'pulling' that change back to our computer.
255255

256-
Let's go to our repository in GitHub and make a change. Underneath where our index.md file is listed you will see a
257-
button to 'Add a README'. Do this now, entering whatever you like, scrolling to the bottom and clicking 'Commit new
256+
Let's go to our repository in GitHub and make a change. Underneath where our index.md file is listed you will see a
257+
button to 'Add a README'. Do this now, entering whatever you like, scrolling to the bottom and clicking 'Commit new
258258
file' (The default commit message will be 'Create README.md', which is fine for our purposes).
259259

260260
> ## The README file
261-
> It is good practice to add a README file to each project to give a brief overview of what the project is about. If you
262-
> put your README file in your repository's root directory, GitHub will recognize and automatically surface your README
261+
> It is good practice to add a README file to each project to give a brief overview of what the project is about. If you
262+
> put your README file in your repository's root directory, GitHub will recognize and automatically surface your README
263263
> to repository visitors
264264
{: .callout}
265265

@@ -269,7 +269,7 @@ our local repository using the `git pull` command.
269269
~~~
270270
$ git pull
271271
~~~
272-
{: .bash}
272+
{: .language-bash }
273273
~~~
274274
remote: Counting objects: 3, done.
275275
remote: Compressing objects: 100% (2/2), done.
@@ -288,6 +288,6 @@ Fast-forward
288288
The above output shows that we have fast-forwarded our local repository to include the file README.md. We could confirm
289289
this by entering the `ls` command.
290290

291-
When we begin collaborating on more complex projects, we may have to consider more aspects of git functionality, but
291+
When we begin collaborating on more complex projects, we may have to consider more aspects of git functionality, but
292292
this should be a good start. In the next section, we can look more closely at collaborating and using GitHub pages to
293293
create a website for our project.

0 commit comments

Comments
 (0)