You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/revision-selection.asc
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,7 +82,8 @@ That’s 1,200 times the number of grains of sand on the earth.
82
82
83
83
Here’s an example to give you an idea of what it would take to get a SHA-1 collision.
84
84
If all 6.5 billion humans on Earth were programming, and every second, each one was producing code that was the equivalent of the entire Linux kernel history (3.6 million Git objects) and pushing it into one enormous Git repository, it would take roughly 2 years until that repository contained enough objects to have a 50% probability of a single SHA-1 object collision.
85
-
A higher probability exists that every member of your programming team will be attacked and killed by wolves in unrelated incidents on the same night.
85
+
Thus, a SHA-1 collision is less likely than every member of your programming team being attacked and killed by wolves in unrelated incidents on the same night.
86
+
86
87
====
87
88
88
89
[[_branch_references]]
@@ -120,7 +121,7 @@ You can see your reflog by using `git reflog`:
d921970 HEAD@{1}: merge phedders/rdocs: Merge made by recursive.
124
+
d921970 HEAD@{1}: merge phedders/rdocs: Merge made by the 'recursive' stategy.
124
125
1c002dd HEAD@{2}: commit: added some blame and merge stuff
125
126
1c36188 HEAD@{3}: rebase -i (squash): updating HEAD
126
127
95df984 HEAD@{4}: commit: # This is a combination of two commits.
@@ -130,7 +131,7 @@ d921970 HEAD@{1}: merge phedders/rdocs: Merge made by recursive.
130
131
131
132
Every time your branch tip is updated for any reason, Git stores that information for you in this temporary history.
132
133
And you can specify older commits with this data, as well.
133
-
If you want to see the fifth prior value of the HEAD of your repository, you can use the `@{n}` reference that you see in the reflog output:
134
+
If you want to see the fifth prior value of the HEAD of your repository, you can use the `@{5}` reference that you see in the reflog output:
134
135
135
136
[source,console]
136
137
----
@@ -275,7 +276,7 @@ image::images/double-dot.png[Example history for range selection.]
275
276
276
277
You want to see what is in your experiment branch that hasn’t yet been merged into your master branch.
277
278
You can ask Git to show you a log of just those commits with `master..experiment` – that means ``all commits reachable by experiment that aren’t reachable by master.''
278
-
For the sake of brevity and clarity in these examples, I’ll use the letters of the commit objects from the diagram in place of the actual log output in the order that they would display:
279
+
For the sake of brevity and clarity in these examples, the letters of the commit objects from the diagram are used in place of the actual log output in the order that they would display:
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/rewriting-history.asc
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ That drops you into your text editor, which has your last commit message in it,
25
25
When you save and close the editor, the editor writes a new commit containing that message and makes it your new last commit.
26
26
27
27
If you’ve committed and then you want to change the snapshot you committed by adding or changing files, possibly because you forgot to add a newly created file when you originally committed, the process works basically the same way.
28
-
You stage the changes you want by editing a file and running `git add` on it or `git rm` to a tracked file, and the subsequent `git commit --amend` takes your current staging area and makes it the snapshot for the new commit.
28
+
You stage the changes you want by editing a file and running `git add` on it or `git rm` to a tracked file, and the subsequent `git commit --amend` takes your current staging area and adds it to the last snapshot making it the snapshot of the last commit.
29
29
30
30
You need to be careful with this technique because amending changes the SHA-1 of the commit.
31
31
It’s like a very small rebase – don’t amend your last commit if you’ve already pushed it.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/searching.asc
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,11 +95,11 @@ As we saw in the above example, we looked for terms in an older version of the G
95
95
Perhaps you're looking not for *where* a term exists, but *when* it existed or was introduced.
96
96
The `git log` command has a number of powerful tools for finding specific commits by the content of their messages or even the content of the diff they introduce.
97
97
98
-
If we want to find out for example when the `ZLIB_BUF_MAX` constant was originally introduced, we can tell Git to only show us the commits that either added or removed that string with the `-S` option.
98
+
If we want to find out for example when the `ZLIB_BUF_MAX` constant was originally introduced, we can use the `-S` option to tell Git to only show us the commits that either added or removed that string.
99
99
100
100
[source,console]
101
101
----
102
-
$ git log -SZLIB_BUF_MAX --oneline
102
+
$ git log -S ZLIB_BUF_MAX --oneline
103
103
e01503b zlib: allow feeding more than 4GB in one go
104
104
ef49a7a zlib: zlib can only process 4GB at a time
105
105
----
@@ -111,8 +111,7 @@ If you need to be more specific, you can provide a regular expression to search
111
111
===== Line Log Search
112
112
113
113
Another fairly advanced log search that is insanely useful is the line history search.
114
-
This is a fairly recent addition and not very well known, but it can be really helpful.
115
-
It is called with the `-L` option to `git log` and will show you the history of a function or line of code in your codebase.
114
+
Simply run `git log` with the `-L` option, and it will show you the history of a function or line of code in your codebase.
116
115
117
116
For example, if we wanted to see every change made to the function `git_deflate_bound` in the `zlib.c` file, we could run `git log -L :git_deflate_bound:zlib.c`.
118
117
This will try to figure out what the bounds of that function are and then look through the history and show us every change that was made to the function as a series of patches back to when the function was first created.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/stashing-cleaning.asc
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,8 @@ no changes added to commit (use "git add" and/or "git commit -a")
79
79
----
80
80
81
81
You can see that Git re-modifies the files you reverted when you saved the stash.
82
-
In this case, you had a clean working directory when you tried to apply the stash, and you tried to apply it on the same branch you saved it from; but having a clean working directory and applying it on the same branch aren’t necessary to successfully apply a stash.
82
+
In this case, you had a clean working directory when you tried to apply the stash, and you tried to apply it on the same branch you saved it from.
83
+
Having a clean working directory and applying it on the same branch aren’t necessary to successfully apply a stash.
83
84
You can save a stash on one branch, switch to another branch later, and try to reapply the changes.
84
85
You can also have modified and uncommitted files in your working directory when you apply a stash – Git gives you merge conflicts if anything no longer applies cleanly.
85
86
@@ -188,7 +189,7 @@ Saved working directory and index state WIP on master: 1b65b17 added the index f
188
189
189
190
If you stash some work, leave it there for a while, and continue on the branch from which you stashed the work, you may have a problem reapplying the work.
190
191
If the apply tries to modify a file that you’ve since modified, you’ll get a merge conflict and will have to try to resolve it.
191
-
If you want an easier way to test the stashed changes again, you can run `git stash branch`, which creates a new branch for you, checks out the commit you were on when you stashed your work, reapplies your work there, and then drops the stash if it applies successfully:
192
+
If you want an easier way to test the stashed changes again, you can run `git stash branch <branch-name>`, which creates a new branch for you with the given `branch-name`, checks out the commit you were on when you stashed your work, reapplies your work there, and then drops the stash if it applies successfully:
0 commit comments