Skip to content

Commit c9bac1d

Browse files
committed
Merge pull request #109 from progit/libgit2_file
libgit2 contains no files named benchmarks.rb
2 parents f0f95d9 + e152bf8 commit c9bac1d

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

book/02-git-basics/sections/recording-changes.asc

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ The `git add` command takes a path name for either a file or a directory; if it'
8686
==== Staging Modified Files
8787

8888
Let's change a file that was already tracked.
89-
If you change a previously tracked file called ``benchmarks.rb'' and then run your `git status` command again, you get something that looks like this:
89+
If you change a previously tracked file called ``CONTRIBUTING.md'' and then run your `git status` command again, you get something that looks like this:
9090

9191
[source,console]
9292
----
@@ -101,68 +101,68 @@ Changes not staged for commit:
101101
(use "git add <file>..." to update what will be committed)
102102
(use "git checkout -- <file>..." to discard changes in working directory)
103103
104-
modified: benchmarks.rb
104+
modified: CONTRIBUTING.md
105105
106106
----
107107

108-
The ``benchmarks.rb'' file appears under a section named ``Changed but not staged for commit'' – which means that a file that is tracked has been modified in the working directory but not yet staged.
108+
The ``CONTRIBUTING.md'' file appears under a section named ``Changed but not staged for commit'' – which means that a file that is tracked has been modified in the working directory but not yet staged.
109109
To stage it, you run the `git add` command. `git add` is a multipurpose command – you use it to begin tracking new files, to stage files, and to do other things like marking merge-conflicted files as resolved. It may be helpful to think of it more as ``add this content to the next commit'' rather than ``add this file to the project''.(((git commands, add)))
110-
Let's run `git add` now to stage the ``benchmarks.rb'' file, and then run `git status` again:
110+
Let's run `git add` now to stage the ``CONTRIBUTING.md'' file, and then run `git status` again:
111111

112112
[source,console]
113113
----
114-
$ git add benchmarks.rb
114+
$ git add CONTRIBUTING.md
115115
$ git status
116116
On branch master
117117
Changes to be committed:
118118
(use "git reset HEAD <file>..." to unstage)
119119
120120
new file: README
121-
modified: benchmarks.rb
121+
modified: CONTRIBUTING.md
122122
123123
----
124124

125125
Both files are staged and will go into your next commit.
126-
At this point, suppose you remember one little change that you want to make in `benchmarks.rb` before you commit it.
126+
At this point, suppose you remember one little change that you want to make in `CONTRIBUTING.md` before you commit it.
127127
You open it again and make that change, and you're ready to commit.
128128
However, let's run `git status` one more time:
129129

130130
[source,console]
131131
----
132-
$ vim benchmarks.rb
132+
$ vim CONTRIBUTING.md
133133
$ git status
134134
On branch master
135135
Changes to be committed:
136136
(use "git reset HEAD <file>..." to unstage)
137137
138138
new file: README
139-
modified: benchmarks.rb
139+
modified: CONTRIBUTING.md
140140
141141
Changes not staged for commit:
142142
(use "git add <file>..." to update what will be committed)
143143
(use "git checkout -- <file>..." to discard changes in working directory)
144144
145-
modified: benchmarks.rb
145+
modified: CONTRIBUTING.md
146146
147147
----
148148

149149
What the heck?
150-
Now `benchmarks.rb` is listed as both staged _and_ unstaged.
150+
Now `CONTRIBUTING.md` is listed as both staged _and_ unstaged.
151151
How is that possible?
152152
It turns out that Git stages a file exactly as it is when you run the `git add` command.
153-
If you commit now, the version of `benchmarks.rb` as it was when you last ran the `git add` command is how it will go into the commit, not the version of the file as it looks in your working directory when you run `git commit`.
153+
If you commit now, the version of `CONTRIBUTING.md` as it was when you last ran the `git add` command is how it will go into the commit, not the version of the file as it looks in your working directory when you run `git commit`.
154154
If you modify a file after you run `git add`, you have to run `git add` again to stage the latest version of the file:
155155

156156
[source,console]
157157
----
158-
$ git add benchmarks.rb
158+
$ git add CONTRIBUTING.md
159159
$ git status
160160
On branch master
161161
Changes to be committed:
162162
(use "git reset HEAD <file>..." to unstage)
163163
164164
new file: README
165-
modified: benchmarks.rb
165+
modified: CONTRIBUTING.md
166166
----
167167

168168
==== Short Status
@@ -248,7 +248,7 @@ We'll cover `git diff` in more detail later, but you'll probably use it most oft
248248
And what have you staged that you are about to commit?
249249
Although `git status` answers those questions very generally by listing the file names, `git diff` shows you the exact lines added and removed – the patch, as it were.
250250

251-
Let's say you edit and stage the `README` file again and then edit the `benchmarks.rb` file without staging it.
251+
Let's say you edit and stage the `README` file again and then edit the `CONTRIBUTING.md` file without staging it.
252252
If you run your `git status` command, you once again see something like this:
253253

254254
[source,console]
@@ -264,18 +264,18 @@ Changes not staged for commit:
264264
(use "git add <file>..." to update what will be committed)
265265
(use "git checkout -- <file>..." to discard changes in working directory)
266266
267-
modified: benchmarks.rb
267+
modified: CONTRIBUTING.md
268268
----
269269

270270
To see what you've changed but not yet staged, type `git diff` with no other arguments:
271271

272272
[source,console]
273273
----
274274
$ git diff
275-
diff --git a/benchmarks.rb b/benchmarks.rb
275+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
276276
index 3cb747f..e445e28 100644
277-
--- a/benchmarks.rb
278-
+++ b/benchmarks.rb
277+
--- a/CONTRIBUTING.md
278+
+++ b/CONTRIBUTING.md
279279
@@ -36,6 +36,10 @@ def main
280280
@commit.parents[0].parents[0].parents[0]
281281
end
@@ -313,35 +313,35 @@ index 0000000..03902a1
313313
It's important to note that `git diff` by itself doesn't show all changes made since your last commit – only changes that are still unstaged.
314314
This can be confusing, because if you've staged all of your changes, `git diff` will give you no output.
315315

316-
For another example, if you stage the `benchmarks.rb` file and then edit it, you can use `git diff` to see the changes in the file that are staged and the changes that are unstaged. If our environment looks like this:
316+
For another example, if you stage the `CONTRIBUTING.md` file and then edit it, you can use `git diff` to see the changes in the file that are staged and the changes that are unstaged. If our environment looks like this:
317317

318318
[source,console]
319319
----
320-
$ git add benchmarks.rb
321-
$ echo '# test line' >> benchmarks.rb
320+
$ git add CONTRIBUTING.md
321+
$ echo '# test line' >> CONTRIBUTING.md
322322
$ git status
323323
On branch master
324324
Changes to be committed:
325325
(use "git reset HEAD <file>..." to unstage)
326326
327-
modified: benchmarks.rb
327+
modified: CONTRIBUTING.md
328328
329329
Changes not staged for commit:
330330
(use "git add <file>..." to update what will be committed)
331331
(use "git checkout -- <file>..." to discard changes in working directory)
332332
333-
modified: benchmarks.rb
333+
modified: CONTRIBUTING.md
334334
----
335335

336336
Now you can use `git diff` to see what is still unstaged
337337

338338
[source,console]
339339
----
340340
$ git diff
341-
diff --git a/benchmarks.rb b/benchmarks.rb
341+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
342342
index e445e28..86b2f7c 100644
343-
--- a/benchmarks.rb
344-
+++ b/benchmarks.rb
343+
--- a/CONTRIBUTING.md
344+
+++ b/CONTRIBUTING.md
345345
@@ -127,3 +127,4 @@ end
346346
main()
347347
@@ -354,10 +354,10 @@ and `git diff --cached` to see what you've staged so far:
354354
[source,console]
355355
----
356356
$ git diff --cached
357-
diff --git a/benchmarks.rb b/benchmarks.rb
357+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
358358
index 3cb747f..e445e28 100644
359-
--- a/benchmarks.rb
360-
+++ b/benchmarks.rb
359+
--- a/CONTRIBUTING.md
360+
+++ b/CONTRIBUTING.md
361361
@@ -36,6 +36,10 @@ def main
362362
@commit.parents[0].parents[0].parents[0]
363363
end
@@ -405,7 +405,7 @@ The editor displays the following text (this example is a Vim screen):
405405
# On branch master
406406
# Changes to be committed:
407407
# new file: README
408-
# modified: benchmarks.rb
408+
# modified: CONTRIBUTING.md
409409
#
410410
~
411411
~
@@ -451,15 +451,15 @@ Changes not staged for commit:
451451
(use "git add <file>..." to update what will be committed)
452452
(use "git checkout -- <file>..." to discard changes in working directory)
453453
454-
modified: benchmarks.rb
454+
modified: CONTRIBUTING.md
455455
456456
no changes added to commit (use "git add" and/or "git commit -a")
457457
$ git commit -a -m 'added new benchmarks'
458458
[master 83e38c7] added new benchmarks
459459
1 file changed, 5 insertions(+), 0 deletions(-)
460460
----
461461

462-
Notice how you don't have to run `git add` on the ``benchmarks.rb'' file in this case before you commit.
462+
Notice how you don't have to run `git add` on the ``CONTRIBUTING.md'' file in this case before you commit.
463463

464464
[[_removing_files]]
465465
==== Removing Files

book/02-git-basics/sections/undoing.asc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ Changes to be committed:
4949
(use "git reset HEAD <file>..." to unstage)
5050
5151
renamed: README.md -> README
52-
modified: benchmarks.rb
52+
modified: CONTRIBUTING.md
5353
----
5454

5555
Right below the ``Changes to be committed'' text, it says use `git reset HEAD <file>...` to unstage.
56-
So, let's use that advice to unstage the `benchmarks.rb` file:
56+
So, let's use that advice to unstage the `CONTRIBUTING.md` file:
5757

5858
[source,console]
5959
----
60-
$ git reset HEAD benchmarks.rb
60+
$ git reset HEAD CONTRIBUTING.md
6161
Unstaged changes after reset:
62-
M benchmarks.rb
62+
M CONTRIBUTING.md
6363
$ git status
6464
On branch master
6565
Changes to be committed:
@@ -71,11 +71,11 @@ Changes not staged for commit:
7171
(use "git add <file>..." to update what will be committed)
7272
(use "git checkout -- <file>..." to discard changes in working directory)
7373
74-
modified: benchmarks.rb
74+
modified: CONTRIBUTING.md
7575
----
7676

7777
The command is a bit strange, but it works.
78-
The `benchmarks.rb` file is modified but once again unstaged.
78+
The `CONTRIBUTING.md` file is modified but once again unstaged.
7979

8080
[NOTE]
8181
=====
@@ -86,7 +86,7 @@ For now this magic invocation is all you need to know about the `git reset` comm
8686

8787
==== Unmodifying a Modified File
8888

89-
What if you realize that you don't want to keep your changes to the `benchmarks.rb` file?
89+
What if you realize that you don't want to keep your changes to the `CONTRIBUTING.md` file?
9090
How can you easily unmodify it – revert it back to what it looked like when you last committed (or initially cloned, or however you got it into your working directory)?
9191
Luckily, `git status` tells you how to do that, too.
9292
In the last example output, the unstaged area looks like this:
@@ -97,15 +97,15 @@ Changes not staged for commit:
9797
(use "git add <file>..." to update what will be committed)
9898
(use "git checkout -- <file>..." to discard changes in working directory)
9999
100-
modified: benchmarks.rb
100+
modified: CONTRIBUTING.md
101101
----
102102

103103
It tells you pretty explicitly how to discard the changes you've made.
104104
Let's do what it says:
105105

106106
[source,console]
107107
----
108-
$ git checkout -- benchmarks.rb
108+
$ git checkout -- CONTRIBUTING.md
109109
$ git status
110110
On branch master
111111
Changes to be committed:

0 commit comments

Comments
 (0)