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: C-git-commands.asc
+23-20Lines changed: 23 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ The `git config` command has been used in nearly every chapter of the book.
19
19
20
20
In <<ch01-getting-started#r_first_time>> we used it to specify our name, email address and editor preference before we even got started using Git.
21
21
22
-
In <<ch02-git-basics#r_git_aliases>> we showed how you could use it to create shorthand commands that expand to long option sequences so you don't have to type them every time.
22
+
In <<ch02-git-basics-chapter#r_git_aliases>> we showed how you could use it to create shorthand commands that expand to long option sequences so you don't have to type them every time.
23
23
24
24
In <<ch03-git-branching#r_rebasing>> we used it to make `--rebase` the default when you run `git pull`.
25
25
@@ -44,7 +44,7 @@ There are two ways to get a Git repository. One is to copy it from an existing r
44
44
45
45
To take a directory and turn it into a new Git repository so you can start version controlling it, you can simply run `git init`.
46
46
47
-
We first introduce this in <<ch02-git-basics#r_getting_a_repo>>, where we show creating a brand new repository to start working with.
47
+
We first introduce this in <<ch02-git-basics-chapter#r_getting_a_repo>>, where we show creating a brand new repository to start working with.
48
48
49
49
We talk briefly about how you can change the default branch from ``master'' in <<ch03-git-branching#r_remote_branches>>.
50
50
@@ -58,7 +58,7 @@ The `git clone` command is actually something of a wrapper around several other
58
58
59
59
The `git clone` command is used in dozens of places throughout the book, but we'll just list a few interesting places.
60
60
61
-
It's basically introduced and explained in <<ch02-git-basics#r_git_cloning>>, where we go through a few examples.
61
+
It's basically introduced and explained in <<ch02-git-basics-chapter#r_git_cloning>>, where we go through a few examples.
62
62
63
63
In <<ch04-git-server#r_git_on_the_server>> we look at using the `--bare` option to create a copy of a Git repository with no working directory.
64
64
@@ -79,7 +79,7 @@ The `git add` command adds content from the working directory into the staging a
79
79
80
80
This command is an incredibly important command in Git and is mentioned or used dozens of times in this book. We'll quickly cover some of the unique uses that can be found.
81
81
82
-
We first introduce and explain `git add` in detail in <<ch02-git-basics#r_tracking_files>>.
82
+
We first introduce and explain `git add` in detail in <<ch02-git-basics-chapter#r_tracking_files>>.
83
83
84
84
We mention how to use it to resolve merge conflicts in <<ch03-git-branching#r_basic_merge_conflicts>>.
85
85
@@ -91,13 +91,13 @@ Finally, we emulate it at a low level in <<ch10-git-internals#r_tree_objects>>,
91
91
92
92
The `git status` command will show you the different states of files in your working directory and staging area. Which files are modified and unstaged and which are staged but not yet committed. In it's normal form, it also will show you some basic hints on how to move files between these stages.
93
93
94
-
We first cover `status` in <<ch02-git-basics#r_checking_status>>, both in it's basic and simplified forms. While we use it throughout the book, pretty much everything you can do with the `git status` command is covered there.
94
+
We first cover `status` in <<ch02-git-basics-chapter#r_checking_status>>, both in it's basic and simplified forms. While we use it throughout the book, pretty much everything you can do with the `git status` command is covered there.
95
95
96
96
==== git diff
97
97
98
98
The `git diff` command is used when you want to see differences between any two trees. This could be the difference between your working environment and your staging area (`git diff` by itself), between your staging area and your last commit (`git diff --staged`), or between two commits (`git diff master branchB`).
99
99
100
-
We first look at the basic uses of `git diff` in <<ch02-git-basics#r_git_diff_staged>>, where we show how to see what changes are staged and which are not yet staged.
100
+
We first look at the basic uses of `git diff` in <<ch02-git-basics-chapter#r_git_diff_staged>>, where we show how to see what changes are staged and which are not yet staged.
101
101
102
102
We use it to look for possible whitespace issues before committing with the `--check` option in <<ch05-distributed-git#r_commit_guidelines>>.
103
103
@@ -111,15 +111,15 @@ Finally, we use it to effectively compare submodule changes with `--submodule` i
111
111
112
112
The `git difftool` command simply launches an external tool to show you the difference between two trees in case you want to use something other than the built in `git diff` command.
113
113
114
-
We only briefly mention this in <<ch02-git-basics#r_git_difftool>>.
114
+
We only briefly mention this in <<ch02-git-basics-chapter#r_git_difftool>>.
115
115
116
116
==== git commit
117
117
118
118
The `git commit` command takes all the file contents that have been staged with `git add` and records a new permanent snapshot in the database and then moves the branch pointer on the current branch up to it.
119
119
120
-
We first cover the basics of committing in <<ch02-git-basics#r_committing_changes>>. There we also demonstrate how to use the `-a` flag to skip the `git add` step in daily workflows and how to use the `-m` flag to pass a commit message in on the command line instead of firing up an editor.
120
+
We first cover the basics of committing in <<ch02-git-basics-chapter#r_committing_changes>>. There we also demonstrate how to use the `-a` flag to skip the `git add` step in daily workflows and how to use the `-m` flag to pass a commit message in on the command line instead of firing up an editor.
121
121
122
-
In <<ch02-git-basics#r_undoing>> we cover using the `--amend` option to redo the most recent commit.
122
+
In <<ch02-git-basics-chapter#r_undoing>> we cover using the `--amend` option to redo the most recent commit.
123
123
124
124
In <<ch03-git-branching#r_git_branches_overview>>, we go into much more detail about what `git commit` does and why it does it like that.
125
125
@@ -131,7 +131,8 @@ Finally, we take a look at what the `git commit` command does in the background
131
131
132
132
The `git reset` command is primarily used to undo things, as you can possibly tell by the verb. It moves around the `HEAD` pointer and optionally changes the `index` or staging area and can also optionally change the working directory if you use `--hard`. This final option makes it possible for this command to lose your work if used incorrectly, so make sure you understand it before using it.
133
133
134
-
We first effectively cover the simplest use of `git reset` in <<ch02-git-basics#r_unstaging>>, where we use it to unstage a file we had run `git add` on.
134
+
We first effectively cover the simplest use of `git reset` in
135
+
<<ch02-git-basics-chapter#r_unstaging>>, where we use it to unstage a file we had run `git add` on.
135
136
136
137
We then cover it in quite some detail in <<ch07-git-tools#r_git_reset>>, which is entirely devoted to explaining this command.
137
138
@@ -141,15 +142,15 @@ We use `git reset --hard` to abort a merge in <<ch07-git-tools#r_abort_merge>>,
141
142
142
143
The `git rm` command is used to remove files from the staging area and working directory for Git. It is similar to `git add` in that it stages a removal of a file for the next commit.
143
144
144
-
We cover the `git rm` command in some detail in <<ch02-git-basics#r_removing_files>>, including recursively removing files and only removing files from the staging area but leaving them in the working directory with `--cached`.
145
+
We cover the `git rm` command in some detail in <<ch02-git-basics-chapter#r_removing_files>>, including recursively removing files and only removing files from the staging area but leaving them in the working directory with `--cached`.
145
146
146
147
The only other differing use of `git rm` in the book is in <<ch10-git-internals#r_removing_objects>> where we briefly use and explain the `--ignore-unmatch` when running `git filter-branch`, which simply makes it not error out when the file we are trying to remove doesn't exist. This can be useful for scripting purposes.
147
148
148
149
==== git mv
149
150
150
151
The `git mv` command is a thin convenience command to move a file and then run `git add` on the new file and `git rm` on the old file.
151
152
152
-
We only briefly mention this command in <<ch02-git-basics#r_git_mv>>.
153
+
We only briefly mention this command in <<ch02-git-basics-chapter#r_git_mv>>.
153
154
154
155
==== git clean
155
156
@@ -211,7 +212,7 @@ The `git log` command is used to show the reachable recorded history of a projec
211
212
212
213
This command is used in nearly every chapter of the book to demonstrate the history of a project.
213
214
214
-
We introduce the command and cover it in some depth in <<ch02-git-basics#r_viewing_history>>. There we look at the `-p` and `--stat` option to get an idea of what was introduced in each commit and the `--pretty` and `--oneline` options to view the history more concisely, along with some simple date and author filtering options.
215
+
We introduce the command and cover it in some depth in <<ch02-git-basics-chapter#r_viewing_history>>. There we look at the `-p` and `--stat` option to get an idea of what was introduced in each commit and the `--pretty` and `--oneline` options to view the history more concisely, along with some simple date and author filtering options.
215
216
216
217
In <<ch03-git-branching#r_create_new_branch>> we use it with the `--decorate` option to easily visualize where our branch pointers are located and we also use the `--graph` option to see what divergent histories look like.
217
218
@@ -235,7 +236,7 @@ This is basically entirely covered in <<ch07-git-tools#r_git_stashing>>.
235
236
236
237
The `git tag` command is used to give a permanent bookmark to a specific point in the code history. Generally this is used for things like releases.
237
238
238
-
This command is introduced and covered in detail in <<ch02-git-basics#r_git_tagging>> and we use it in practice in <<ch05-distributed-git#r_tagging_releases>>.
239
+
This command is introduced and covered in detail in <<ch02-git-basics-chapter#r_git_tagging>> and we use it in practice in <<ch05-distributed-git#r_tagging_releases>>.
239
240
240
241
We also cover how to create a GPG signed tag with the `-s` flag and verify one with the `-v` flag in <<ch07-git-tools#r_signing>>.
241
242
@@ -248,7 +249,7 @@ There are not very many commands in Git that access the network, nearly all of t
248
249
249
250
The `git fetch` command communicates with a remote repository and fetches down all the information that is in that repository that is not in your current one and stores it in your local database.
250
251
251
-
We first look at this command in <<ch02-git-basics#r_fetching_and_pulling>> and we continue to see examples of it use in <<ch03-git-branching#r_remote_branches>>.
252
+
We first look at this command in <<ch02-git-basics-chapter#r_fetching_and_pulling>> and we continue to see examples of it use in <<ch03-git-branching#r_remote_branches>>.
252
253
253
254
We also use it in several of the examples in <<ch05-distributed-git#r_contributing_project>>.
254
255
@@ -260,7 +261,8 @@ We set up highly custom refspecs in order to make `git fetch` do something a lit
260
261
261
262
The `git pull` command is basically a combination of the `git fetch` and `git merge` commands, where Git will fetch from the remote you specify and then immediately try to merge it into the branch you're on.
262
263
263
-
We introduce it quicking in <<ch02-git-basics#r_fetching_and_pulling>> and show how to see what it will merge if you run it in <<ch02-git-basics#r_inspecting_remote>>.
264
+
We introduce it quicking in <<ch02-git-basics-chapter#r_fetching_and_pulling>> and
265
+
show how to see what it will merge if you run it in <<ch02-git-basics-chapter#r_inspecting_remote>>.
264
266
265
267
We also see how to use it to help with rebasing difficulties in <<ch03-git-branching#r_rebase_rebase>>.
266
268
@@ -272,11 +274,12 @@ Finally, we very quickly mention that you can use the `--verify-signatures` opti
272
274
273
275
The `git push` command is used to communicate with another repository, calculate what your local database has that the remote one does not, and then pushes the difference into the other repository. It requires write access to the other repository and so normally is authenticated somehow.
274
276
275
-
We first look at the `git push` command in <<ch02-git-basics#r_pushing_remotes>>. Here we cover the basics of pushing a branch to a remote repository. In <<ch03-git-branching#r_pushing_branches>> we go a little deeper into pushing specific branches and in <<ch03-git-branching#r_tracking_branches>> we see how to set up tracking branches to automatically push to. In <<ch03-git-branching#r_delete_branches>> we use the `--delete` flag to delete a branch on the server with `git push`.
277
+
We first look at the `git push` command in <<ch02-git-basics-chapter#r_pushing_remotes>>. Here we cover the basics of pushing a branch to a remote repository. In <<ch03-git-branching#r_pushing_branches>> we go a little deeper into pushing specific branches and in <<ch03-git-branching#r_tracking_branches>> we see how to set up tracking branches to automatically push to. In <<ch03-git-branching#r_delete_branches>> we use the `--delete` flag to delete a branch on the server with `git push`.
276
278
277
279
Throughout <<ch05-distributed-git#r_contributing_project>> we see several examples of using `git push` to share work on branches through multiple remotes.
278
280
279
-
We see how to use it to share tags that you have made with the `--tags` option in <<ch02-git-basics#r_sharing_tags>>.
281
+
We see how to use it to share tags that you have made with the `--tags` option in
282
+
<<ch02-git-basics-chapter#r_sharing_tags>>.
280
283
281
284
In <<ch07-git-tools#r_publishing_submodules>> we use the `--recurse-submodules` option to check that all of our submodules work has been published before pushing the superproject, which can be really helpful when using submodules.
282
285
@@ -288,7 +291,7 @@ Finally, in <<ch10-git-internals#r_pushing_refspecs>> we look at pushing with a
288
291
289
292
The `git remote` command is a management tool for your record of remote repositories. It allows you to save long URLs as short handles, such as ``origin'' so you don't have to type them out all the time. You can have several of these and the `git remote` command is used to add, change and delete them.
290
293
291
-
This command is covered in detail in <<ch02-git-basics#r_remote_repos>>, including listing, adding, removing and renaming them.
294
+
This command is covered in detail in <<ch02-git-basics-chapter#r_remote_repos>>, including listing, adding, removing and renaming them.
292
295
293
296
It is used in nearly every subsequent chapter in the book too, but always in the standard `git remote add <name> <url>` format.
294
297
@@ -310,7 +313,7 @@ This command is only mentioned and entirely covered in <<ch07-git-tools#r_git_su
310
313
311
314
The `git show` command can show a Git object in a simple and human readable way. Normally you would use this to show the information about a tag or a commit.
312
315
313
-
We first use it to show annotated tag information in <<ch02-git-basics#r_annotated_tags>>.
316
+
We first use it to show annotated tag information in <<ch02-git-basics-chapter#r_annotated_tags>>.
314
317
315
318
Later we use it quite a bit in <<ch07-git-tools#r_revision_selection>> to show the commits that our various revision selections resolve to.
Copy file name to clipboardExpand all lines: book/01-introduction/sections/what-is-git.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
@@ -71,7 +71,7 @@ It is hard to get the system to do anything that is not undoable or to make it e
71
71
As with any VCS, you can lose or mess up changes you haven't committed yet, but after you commit a snapshot into Git, it is very difficult to lose, especially if you regularly push your database to another repository.
72
72
73
73
This makes using Git a joy because we know we can experiment without the danger of severely screwing things up.
74
-
For a more in-depth look at how Git stores its data and how you can recover data that seems lost, see <<ch02-git-basics-chapter#_undoing>>.
74
+
For a more in-depth look at how Git stores its data and how you can recover data that seems lost, see <<ch02-git-basics-chapter#undoing>>.
Copy file name to clipboardExpand all lines: book/03-git-branching/sections/remote-branches.asc
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,9 @@ image::images/remote-branches-3.png[`git fetch` updates your remote references.]
38
38
39
39
To demonstrate having multiple remote servers and what remote branches for those remote projects look like, let's assume you have another internal Git server that is used only for development by one of your sprint teams.
40
40
This server is at `git.team1.ourcompany.com`.
41
-
You can add it as a new remote reference to the project you're currently working on by running the `git remote add` command as we covered in <<ch02-git-basics#ch02-git-basics>>.
41
+
You can add it as a new remote reference to the project you're currently working
42
+
on by running the `git remote add` command as we covered in
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/submodules.asc
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -721,7 +721,9 @@ Here we can see that we're defining a function in a submodule and calling it in
721
721
722
722
===== Useful Aliases
723
723
724
-
You may want to set up some aliases for some of these commands as they can be quite long and you can't set configuration options for most of them to make them defaults. We covered setting up Git aliases in <<ch02-git-basics#r_git_aliases>>, but here is an example of what you may want to set up if you plan on working with submodules in Git a lot.
724
+
You may want to set up some aliases for some of these commands as they can be
725
+
quite long and you can't set configuration options for most of them to make them
726
+
defaults. We covered setting up Git aliases in <<ch02-git-basics-chapter#r_git_aliases>>, but here is an example of what you may want to set up if you plan on working with submodules in Git a lot.
Copy file name to clipboardExpand all lines: book/08-customizing-git/sections/config.asc
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,7 +141,9 @@ $ git tag -s <tag-name>
141
141
===== `core.excludesfile`
142
142
143
143
(((excludes)))(((.gitignore)))
144
-
You can put patterns in your project's `.gitignore` file to have Git not see them as untracked files or try to stage them when you run `git add` on them, as discussed in <<ch02-git-basics#r_ignoring>>.
144
+
You can put patterns in your project's `.gitignore` file to have Git not see them
145
+
as untracked files or try to stage them when you run `git add` on them, as
146
+
discussed in <<ch02-git-basics-chapter#r_ignoring>>.
145
147
146
148
But sometimes you want to ignore certain files for all repositories that you work with.
147
149
If your computer is running Mac OS X, you're probably familiar with `.DS_Store` files.
0 commit comments