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: README.asc
+9-4
Original file line number
Diff line number
Diff line change
@@ -6,19 +6,24 @@ You can find this book online at: http://git-scm.com/book
6
6
7
7
Like the first edition, the second edition of Pro Git is open source under a Creative Commons license.
8
8
9
-
A couple of things have changed since open sourcing the first edition. For one, we've moved from Markdown to the amazing Asciidoc format for the text of the book. We've also moved to using O'Reilly's https://atlas.oreilly.com[Atlas platform] for generating continuous builds of the book so all major formats are always available in every language.
9
+
A couple of things have changed since open sourcing the first edition.
10
+
For one, we've moved from Markdown to the amazing Asciidoc format for the text of the book.
11
+
We've also moved to using O'Reilly's https://atlas.oreilly.com[Atlas platform] for generating continuous builds of the book so all major formats are always available in every language.
10
12
11
-
We've also moved to keeping the translations in separate repositories rather than subdirectories of the English repository. See link:CONTRIBUTING.md[the Contributing document] for more information.
13
+
We've also moved to keeping the translations in separate repositories rather than subdirectories of the English repository.
14
+
See link:CONTRIBUTING.md[the Contributing document] for more information.
12
15
13
16
== How To Generate the Book
14
17
15
18
There are two ways to generate e-book content from this source code.
16
19
17
-
The easiest way is simply to let us do it. A robot is standing by to look for new work on the main branch and automatically build it for everyone.
20
+
The easiest way is simply to let us do it.
21
+
A robot is standing by to look for new work on the main branch and automatically build it for everyone.
18
22
19
23
You can find the current builds on http://git-scm.com/book[] and more information about the builds available at https://progit.org[].
20
24
21
-
The other way to generate e-book files is to do so manually with Asciidoctor. If you run the following you _may_ actually get HTML, Epub, Mobi and PDF output files:
25
+
The other way to generate e-book files is to do so manually with Asciidoctor.
26
+
If you run the following you _may_ actually get HTML, Epub, Mobi and PDF output files:
After forking this repository to translate the work, this file is where the notes for coordinating the translation work would go. Things like standardizing on words and expressions so that the work is consistent or notes on how the contributing process is to be handled.
3
+
After forking this repository to translate the work, this file is where the notes for coordinating the translation work would go.
4
+
Things like standardizing on words and expressions so that the work is consistent or notes on how the contributing process is to be handled.
4
5
5
6
As a translation maintainer, also feel free to modify or completely rewrite the README file to contain instructions specific to your translation.
6
7
7
8
=== Translation Status
8
9
9
-
As the work is translated, please update the `status.json` file to indicate the rough percentage complete each file is. This will be shown on various pages to let people know how much work is left to be done.
10
+
As the work is translated, please update the `status.json` file to indicate the rough percentage complete each file is.
11
+
This will be shown on various pages to let people know how much work is left to be done.
Vim and Emacs are popular text editors often used by developers on Unix based systems like Linux and Mac. If you are not familiar with either of these editors or are on a Windows system, you may need to search for instructions for how to set up your favorite editor with Git.
51
+
Vim and Emacs are popular text editors often used by developers on Unix based systems like Linux and Mac.
52
+
If you are not familiar with either of these editors or are on a Windows system, you may need to search for instructions for how to set up your favorite editor with Git.
52
53
If you don't set an editor like this and you don't know what Vim or Emacs are, you will likely get into a really confusing state when they are launched.
Copy file name to clipboardexpand all lines: book/01-introduction/sections/installing.asc
+3-1
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,9 @@ You can either install it as a package or via another installer, or download the
6
6
7
7
[NOTE]
8
8
====
9
-
This book was written using Git version *2.0.0*. Though most of the commands we use should work even in ancient versions of Git, some of them might not or might act slightly differently if you're using an older version. Since Git is quite excellent at preserving backwards compatibility, any version after 2.0 should work just fine.
9
+
This book was written using Git version *2.0.0*.
10
+
Though most of the commands we use should work even in ancient versions of Git, some of them might not or might act slightly differently if you're using an older version.
11
+
Since Git is quite excellent at preserving backwards compatibility, any version after 2.0 should work just fine.
This means we can pull contributions from any of these users pretty easily. We may additionally have permission to push to one or more of these, though we can't tell that here.
59
+
This means we can pull contributions from any of these users pretty easily.
60
+
We may additionally have permission to push to one or more of these, though we can't tell that here.
60
61
61
62
Notice that these remotes use a variety of protocols; we'll cover more about this in <<_git_on_the_server>>.
Copy file name to clipboardexpand all lines: book/02-git-basics/sections/undoing.asc
+6-3
Original file line number
Diff line number
Diff line change
@@ -79,10 +79,12 @@ The `CONTRIBUTING.md` file is modified but once again unstaged.
79
79
80
80
[NOTE]
81
81
=====
82
-
While `git reset` _can_ be a dangerous command if you call it with `--hard`, in this instance the file in your working directory is not touched. Calling `git reset` without an option is not dangerous - it only touches your staging area.
82
+
While `git reset` _can_ be a dangerous command if you call it with `--hard`, in this instance the file in your working directory is not touched.
83
+
Calling `git reset` without an option is not dangerous - it only touches your staging area.
83
84
=====
84
85
85
-
For now this magic invocation is all you need to know about the `git reset` command. We'll go into much more detail about what `reset` does and how to master it to do really interesting things in <<_git_reset>>.
86
+
For now this magic invocation is all you need to know about the `git reset` command.
87
+
We'll go into much more detail about what `reset` does and how to master it to do really interesting things in <<_git_reset>>.
86
88
87
89
==== Unmodifying a Modified File
88
90
@@ -119,7 +121,8 @@ You can see that the changes have been reverted.
119
121
120
122
[IMPORTANT]
121
123
=====
122
-
It's important to understand that `git checkout -- [file]` is a dangerous command. Any changes you made to that file are gone – you just copied another file over it.
124
+
It's important to understand that `git checkout -- [file]` is a dangerous command.
125
+
Any changes you made to that file are gone – you just copied another file over it.
123
126
Don't ever use this command unless you absolutely know that you don't want the file.
Copy file name to clipboardexpand all lines: book/02-git-basics/sections/viewing-history.asc
+2-1
Original file line number
Diff line number
Diff line change
@@ -245,7 +245,8 @@ You can also filter the list to commits that match some search criteria.
245
245
The `--author` option allows you to filter on a specific author, and the `--grep` option lets you search for keywords in the commit messages.
246
246
(Note that if you want to specify both author and grep options, you have to add `--all-match` or the command will match commits with either.)
247
247
248
-
Another really helpful filter is the `-S` option which takes a string and only shows the commits that introduced a change to the code that added or removed that string. For instance, if you wanted to find the last commit that added or removed a reference to a specific function, you could call:
248
+
Another really helpful filter is the `-S` option which takes a string and only shows the commits that introduced a change to the code that added or removed that string.
249
+
For instance, if you wanted to find the last commit that added or removed a reference to a specific function, you could call:
Copy file name to clipboardexpand all lines: book/03-git-branching/sections/nutshell.asc
+2-1
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,8 @@ The `git branch` command only _created_ a new branch – it didn't switch to tha
74
74
.HEAD pointing to a branch
75
75
image::images/head-to-master.png[HEAD pointing to a branch.]
76
76
77
-
You can easily see this by running a simple `git log` command that shows you where the branch pointers are pointing. This option is called `--decorate`.
77
+
You can easily see this by running a simple `git log` command that shows you where the branch pointers are pointing.
Copy file name to clipboardexpand all lines: book/03-git-branching/sections/rebasing.asc
+8-4
Original file line number
Diff line number
Diff line change
@@ -179,9 +179,11 @@ It's pretty safe to assume that the other developer doesn't want `C4` and `C6` t
179
179
[[_rebase_rebase]]
180
180
==== Rebase When You Rebase
181
181
182
-
If you *do* find yourself in a situation like this, Git has some further magic that might help you out. If someone on your team force pushes changes that overwrite work that you've based work on, your challenge is to figure out what is yours and what they've rewritten.
182
+
If you *do* find yourself in a situation like this, Git has some further magic that might help you out.
183
+
If someone on your team force pushes changes that overwrite work that you've based work on, your challenge is to figure out what is yours and what they've rewritten.
183
184
184
-
It turns out that in addition to the commit SHA-1 checksum, Git also calculates a checksum that is based just on the patch introduced with the commit. This is called a ``patch-id''.
185
+
It turns out that in addition to the commit SHA-1 checksum, Git also calculates a checksum that is based just on the patch introduced with the commit.
186
+
This is called a ``patch-id''.
185
187
186
188
If you pull down work that was rewritten and rebase it on top of the new commits from your partner, Git can often successfully figure out what is uniquely yours and apply them back on top of the new branch.
187
189
@@ -198,9 +200,11 @@ So instead of the result we see in <<_merge_rebase_work>>, we would end up with
198
200
.Rebase on top of force-pushed rebase work.
199
201
image::images/perils-of-rebasing-5.png[Rebase on top of force-pushed rebase work.]
200
202
201
-
This only works if C4 and C4' that your partner made are almost exactly the same patch. Otherwise the rebase won't be able to tell that it's a duplicate and will add another C4-like patch (which will probably fail to apply cleanly, since the changes would already be at least somewhat there).
203
+
This only works if C4 and C4' that your partner made are almost exactly the same patch.
204
+
Otherwise the rebase won't be able to tell that it's a duplicate and will add another C4-like patch (which will probably fail to apply cleanly, since the changes would already be at least somewhat there).
202
205
203
-
You can also simplify this by running a `git pull --rebase` instead of a normal `git pull`. Or you could do it manually with a `git fetch` followed by a `git rebase teamone/master` in this case.
206
+
You can also simplify this by running a `git pull --rebase` instead of a normal `git pull`.
207
+
Or you could do it manually with a `git fetch` followed by a `git rebase teamone/master` in this case.
204
208
205
209
If you are using `git pull` and want to make `--rebase` the default, you can set the `pull.rebase` config value with something like `git config --global pull.rebase true`.
Copy file name to clipboardexpand all lines: book/03-git-branching/sections/remote-branches.asc
+21-8
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,9 @@ Git also gives you your own local `master` branch starting at the same place as
22
22
[NOTE]
23
23
.``origin'' is not special
24
24
====
25
-
Just like the branch name ``master'' does not have any special meaning in Git, neither does ``origin''. While ``master'' is the default name for a starting branch when you run `git init` which is the only reason it's widely used, ``origin'' is the default name for a remote when you run `git clone`. If you run `git clone -o booyah` instead, then you will have `booyah/master` as your default remote branch.(((origin)))
25
+
Just like the branch name ``master'' does not have any special meaning in Git, neither does ``origin''.
26
+
While ``master'' is the default name for a starting branch when you run `git init` which is the only reason it's widely used, ``origin'' is the default name for a remote when you run `git clone`.
27
+
If you run `git clone -o booyah` instead, then you will have `booyah/master` as your default remote branch.(((origin)))
26
28
====
27
29
28
30
.Server and local repositories after cloning
@@ -87,9 +89,11 @@ If you didn't want it to be called `serverfix` on the remote, you could instead
87
89
[NOTE]
88
90
.Don't type your password every time
89
91
====
90
-
If you're using an HTTPS URL to push over, the Git server will ask you for your username and password for authentication. By default it will prompt you on the terminal for this information so the server can tell if you're allowed to push.
92
+
If you're using an HTTPS URL to push over, the Git server will ask you for your username and password for authentication.
93
+
By default it will prompt you on the terminal for this information so the server can tell if you're allowed to push.
91
94
92
-
If you don't want to type it every single time you push, you can set up a ``credential cache''. The simplest is just to keep it in memory for a few minutes, which you can easily set up by running `git config --global credential.helper cache`.
95
+
If you don't want to type it every single time you push, you can set up a ``credential cache''.
96
+
The simplest is just to keep it in memory for a few minutes, which you can easily set up by running `git config --global credential.helper cache`.
93
97
94
98
For more information on the various credential caching options available, see <<_credential_caching>>.
95
99
====
@@ -164,10 +168,12 @@ Branch serverfix set up to track remote branch serverfix from origin.
164
168
[NOTE]
165
169
.Upstream shorthand
166
170
====
167
-
When you have a tracking branch set up, you can reference it with the `@{upstream}` or `@{u}` shorthand. So if you're on the `master` branch and it's tracking `origin/master`, you can say something like `git merge @{u}` instead of `git merge origin/master` if you wish.(((+++@{u}+++)))(((+++@{upstream}+++)))
171
+
When you have a tracking branch set up, you can reference it with the `@{upstream}` or `@{u}` shorthand.
172
+
So if you're on the `master` branch and it's tracking `origin/master`, you can say something like `git merge @{u}` instead of `git merge origin/master` if you wish.(((+++@{u}+++)))(((+++@{upstream}+++)))
168
173
====
169
174
170
-
If you want to see what tracking branches you have set up, you can use the `-vv` option to `git branch`. This will list out your local branches with more information including what each branch is tracking and if your local branch is ahead, behind or both.
175
+
If you want to see what tracking branches you have set up, you can use the `-vv` option to `git branch`.
176
+
This will list out your local branches with more information including what each branch is tracking and if your local branch is ahead, behind or both.
171
177
172
178
[source,console]
173
179
----
@@ -178,9 +184,15 @@ $ git branch -vv
178
184
testing 5ea463a trying something new
179
185
----
180
186
181
-
So here we can see that our `iss53` branch is tracking `origin/iss53` and is ``ahead'' by two, meaning that we have two commits locally that are not pushed to the server. We can also see that our `master` branch is tracking `origin/master` and is up to date. Next we can see that our `serverfix` branch is tracking the `server-fix-good` branch on our `teamone` server and is ahead by three and behind by one, meaning that there is one commit on the server we haven't merged in yet and three commits locally that we haven't pushed. Finally we can see that our `testing` branch is not tracking any remote branch.
187
+
So here we can see that our `iss53` branch is tracking `origin/iss53` and is ``ahead'' by two, meaning that we have two commits locally that are not pushed to the server.
188
+
We can also see that our `master` branch is tracking `origin/master` and is up to date.
189
+
Next we can see that our `serverfix` branch is tracking the `server-fix-good` branch on our `teamone` server and is ahead by three and behind by one, meaning that there is one commit on the server we haven't merged in yet and three commits locally that we haven't pushed.
190
+
Finally we can see that our `testing` branch is not tracking any remote branch.
182
191
183
-
It's important to note that these numbers are only since the last time you fetched from each server. This command does not reach out to the servers, it's telling you about what it has cached from these servers locally. If you want totally up to date ahead and behind numbers, you'll need to fetch from all your remotes right before running this. You could do that like this: `$ git fetch --all; git branch -vv`
192
+
It's important to note that these numbers are only since the last time you fetched from each server.
193
+
This command does not reach out to the servers, it's telling you about what it has cached from these servers locally.
194
+
If you want totally up to date ahead and behind numbers, you'll need to fetch from all your remotes right before running this.
195
+
You could do that like this: `$ git fetch --all; git branch -vv`
184
196
185
197
==== Pulling
186
198
@@ -207,4 +219,5 @@ To https://github.com/schacon/simplegit
207
219
- [deleted] serverfix
208
220
----
209
221
210
-
Basically all this does is remove the pointer from the server. The Git server will generally keep the data there for a while until a garbage collection runs, so if it was accidentally deleted, it's often easy to recover.
222
+
Basically all this does is remove the pointer from the server.
223
+
The Git server will generally keep the data there for a while until a garbage collection runs, so if it was accidentally deleted, it's often easy to recover.
Copy file name to clipboardexpand all lines: book/04-git-server/sections/git-daemon.asc
+5-2
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
=== Git Daemon
2
2
3
3
(((serving repositories, git protocol)))
4
-
Next we'll set up a daemon serving repositories over the ``Git'' protocol. This is common choice for fast, unauthenticated access to your Git data. Remember that since it's not an authenticated service, anything you serve over this protocol is public within its network.
4
+
Next we'll set up a daemon serving repositories over the ``Git'' protocol.
5
+
This is common choice for fast, unauthenticated access to your Git data.
6
+
Remember that since it's not an authenticated service, anything you serve over this protocol is public within its network.
5
7
6
8
If you're running this on a server outside your firewall, it should only be used for projects that are publicly visible to the world.
7
9
If the server you're running it on is inside your firewall, you might use it for projects that a large number of people or computers (continuous integration or build servers) have read-only access to, when you don't want to have to add an SSH key for each.
@@ -53,7 +55,8 @@ initctl start local-git-daemon
53
55
54
56
On other systems, you may want to use `xinetd`, a script in your `sysvinit` system, or something else – as long as you get that command daemonized and watched somehow.
55
57
56
-
Next, you have to tell Git which repositories to allow unauthenticated Git server-based access to. You can do this in each repository by creating a file named `git-daemon-export-ok`.
58
+
Next, you have to tell Git which repositories to allow unauthenticated Git server-based access to.
59
+
You can do this in each repository by creating a file named `git-daemon-export-ok`.
0 commit comments