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
This type of output will become more interesting as we go through branching and merging in the next chapter.
206
206
207
207
Those are only some simple output-formatting options to `git log` -- there are many more.
208
-
<<log_options>> lists the options we've covered so far, as well as some other common formatting options that may be useful, along with how they change the output of the log command.
208
+
<<log_options>> lists the options we've covered so far, as well as some other common formatting options that may be useful, along with how they change the output of the `log` command.
209
209
210
210
[[log_options]]
211
211
.Common options to `git log`
@@ -214,13 +214,13 @@ Those are only some simple output-formatting options to `git log` -- there are m
214
214
| Option | Description
215
215
| `-p` | Show the patch introduced with each commit.
216
216
| `--stat` | Show statistics for files modified in each commit.
217
-
| `--shortstat` | Display only the changed/insertions/deletions line from the --stat command.
217
+
| `--shortstat` | Display only the changed/insertions/deletions line from the `--stat` command.
218
218
| `--name-only` | Show the list of files modified after the commit information.
219
219
| `--name-status` | Show the list of files affected with added/modified/deleted information as well.
220
220
| `--abbrev-commit` | Show only the first few characters of the SHA-1 checksum instead of all 40.
221
221
| `--relative-date` | Display the date in a relative format (for example, "`2 weeks ago`") instead of using the full date format.
222
222
| `--graph` | Display an ASCII graph of the branch and merge history beside the log output.
223
-
| `--pretty` | Show commits in an alternate format. Option values include oneline, short, full, fuller, and format (where you specify your own format).
223
+
| `--pretty` | Show commits in an alternate format. Option values include `oneline`, `short`, `full`, `fuller`, and `format` (where you specify your own format).
224
224
| `--oneline` | Shorthand for `--pretty=oneline --abbrev-commit` used together.
225
225
|================================
226
226
@@ -305,5 +305,5 @@ Of the nearly 40,000 commits in the Git source code history, this command shows
305
305
.Preventing the display of merge commits
306
306
====
307
307
Depending on the workflow used in your repository, it's possible that a sizable percentage of the commits in your log history are just merge commits, which typically aren't very informative.
308
-
To prevent the display of merge commits cluttering up your log history, simply add the log option `--no-merges`.
308
+
To prevent the display of merge commits cluttering up your log history, simply add the `log` option `--no-merges`.
Copy file name to clipboardExpand all lines: book/03-git-branching/sections/rebasing.asc
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ You can also have your rebase replay on something other than the rebase target b
66
66
Take a history like <<rbdiag_e>>, for example.
67
67
You branched a topic branch (`server`) to add some server-side functionality to your project, and made a commit.
68
68
Then, you branched off that to make the client-side changes (`client`) and committed a few times.
69
-
Finally, you went back to your server branch and did a few more commits.
69
+
Finally, you went back to your `server` branch and did a few more commits.
70
70
71
71
[[rbdiag_e]]
72
72
.A history with a topic branch off another topic branch
@@ -95,10 +95,10 @@ $ git merge client
95
95
----
96
96
97
97
[[rbdiag_g]]
98
-
.Fast-forwarding your `master` branch to include the client branch changes
99
-
image::images/interesting-rebase-3.png[Fast-forwarding your `master` branch to include the client branch changes]
98
+
.Fast-forwarding your `master` branch to include the `client` branch changes
99
+
image::images/interesting-rebase-3.png[Fast-forwarding your `master` branch to include the `client` branch changes]
100
100
101
-
Let's say you decide to pull in your server branch as well.
101
+
Let's say you decide to pull in your `server` branch as well.
102
102
You can rebase the `server` branch onto the `master` branch without having to check it out first by running `git rebase <basebranch> <topicbranch>` -- which checks out the topic branch (in this case, `server`) for you and replays it onto the base branch (`master`):
103
103
104
104
[source,console]
@@ -109,8 +109,8 @@ $ git rebase master server
109
109
This replays your `server` work on top of your `master` work, as shown in <<rbdiag_h>>.
110
110
111
111
[[rbdiag_h]]
112
-
.Rebasing your server branch on top of your `master` branch
113
-
image::images/interesting-rebase-4.png[Rebasing your server branch on top of your `master` branch]
112
+
.Rebasing your `server` branch on top of your `master` branch
113
+
image::images/interesting-rebase-4.png[Rebasing your `server` branch on top of your `master` branch]
114
114
115
115
Then, you can fast-forward the base branch (`master`):
116
116
@@ -190,9 +190,9 @@ If you pull down work that was rewritten and rebase it on top of the new commits
190
190
191
191
For instance, in the previous scenario, if instead of doing a merge when we're at <<_pre_merge_rebase_work>> we run `git rebase teamone/master`, Git will:
192
192
193
-
* Determine what work is unique to our branch (C2, C3, C4, C6, C7)
194
-
* Determine which are not merge commits (C2, C3, C4)
195
-
* Determine which have not been rewritten into the target branch (just C2 and C3, since C4 is the same patch as C4')
193
+
* Determine what work is unique to our branch (`C2`, `C3`, `C4`, `C6`, `C7`)
194
+
* Determine which are not merge commits (`C2`, `C3`, `C4`)
195
+
* Determine which have not been rewritten into the target branch (just `C2` and `C3`, since `C4` is the same patch as `C4'`)
196
196
* Apply those commits to the top of `teamone/master`
197
197
198
198
So instead of the result we see in <<_merge_rebase_work>>, we would end up with something more like <<_rebase_rebase_work>>.
@@ -202,7 +202,7 @@ So instead of the result we see in <<_merge_rebase_work>>, we would end up with
202
202
image::images/perils-of-rebasing-5.png[Rebase on top of force-pushed rebase work]
203
203
204
204
This only works if `C4` and `C4'` that your partner made are almost exactly the same patch.
205
-
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).
205
+
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).
206
206
207
207
You can also simplify this by running a `git pull --rebase` instead of a normal `git pull`.
208
208
Or you could do it manually with a `git fetch` followed by a `git rebase teamone/master` in this case.
@@ -230,7 +230,7 @@ That's how it happened, and the repository should preserve that for posterity.
230
230
The opposing point of view is that the commit history is the *story of how your project was made.*
231
231
You wouldn't publish the first draft of a book, so why show your messy work?
232
232
When you're working on a project, you may need a record of all your missteps and dead-end paths, but when it's time to show your work to the world, you may want to tell a more coherent story of how to get from A to B.
233
-
People in this camp use tools like rebase and filter-branch to rewrite their commits before they're merged into the mainline branch.
233
+
People in this camp use tools like `rebase` and `filter-branch` to rewrite their commits before they're merged into the mainline branch.
234
234
They use tools like `rebase` and `filter-branch`, to tell the story in the way that's best for future readers.
235
235
236
236
Now, to the question of whether merging or rebasing is better: hopefully you'll see that it's not that simple.
Copy file name to clipboardExpand all lines: book/05-distributed-git/sections/maintaining.asc
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ Now you're ready to add the contributed work that you received into this topic b
35
35
If you receive a patch over email that you need to integrate into your project, you need to apply the patch in your topic branch to evaluate it.
36
36
There are two ways to apply an emailed patch: with `git apply` or with `git am`.
37
37
38
-
===== Applying a Patch with apply
38
+
===== Applying a Patch with `apply`
39
39
40
40
(((git commands, apply)))
41
41
If you received the patch from someone who generated it with `git diff` or some variation of the Unix `diff` command (which is not recommended; see the next section), you can apply it with the `git apply` command.
@@ -533,7 +533,7 @@ You now have a nice tarball and a zip archive of your project release that you c
533
533
(((git commands, shortlog)))
534
534
It's time to email your mailing list of people who want to know what's happening in your project.
535
535
A nice way of quickly getting a sort of changelog of what has been added to your project since your last release or email is to use the `git shortlog` command.
536
-
It summarizes all the commits in the range you give it; for example, the following gives you a summary of all the commits since your last release, if your last release was named v1.0.1:
536
+
It summarizes all the commits in the range you give it; for example, the following gives you a summary of all the commits since your last release, if your last release was named `v1.0.1`:
537
537
538
538
[source,console]
539
539
----
@@ -553,4 +553,4 @@ Tom Preston-Werner (4):
553
553
Regenerated gemspec for version 1.0.2
554
554
----
555
555
556
-
You get a clean summary of all the commits since v1.0.1, grouped by author, that you can email to your list.
556
+
You get a clean summary of all the commits since `v1.0.1`, grouped by author, that you can email to your list.
Copy file name to clipboardExpand all lines: book/06-github/sections/2-contributing.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
@@ -42,7 +42,7 @@ Here's how it generally works:
42
42
5. Open a Pull Request on GitHub.
43
43
6. Discuss, and optionally continue committing.
44
44
7. The project owner merges or closes the Pull Request.
45
-
8. Sync the updated master back to your fork.
45
+
8. Sync the updated `master` back to your fork.
46
46
47
47
This is basically the Integration Manager workflow covered in <<ch05-distributed-git#_integration_manager>>, but instead of using email to communicate and review changes, teams use GitHub's web based tools.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/credentials.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
@@ -116,7 +116,7 @@ For the `get` action, however, Git is very interested in what the helper has to
116
116
If the helper doesn't know anything useful, it can simply exit with no output, but if it does know, it should augment the provided information with the information it has stored.
117
117
The output is treated like a series of assignment statements; anything provided will replace what Git already knows.
118
118
119
-
Here's the same example from above, but skipping git-credential and going straight for git-credential-store:
119
+
Here's the same example from above, but skipping `git-credential` and going straight for `git-credential-store`:
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/reset.asc
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -171,7 +171,7 @@ When you run `git commit`, Git creates a new commit and moves the branch that HE
171
171
When you `reset` back to `HEAD~` (the parent of HEAD), you are moving the branch back to where it was, without changing the index or working directory.
172
172
You could now update the index and run `git commit` again to accomplish what `git commit --amend` would have done (see <<_git_amend>>).
173
173
174
-
===== Step 2: Updating the Index (--mixed)
174
+
===== Step 2: Updating the Index (`--mixed`)
175
175
176
176
Note that if you run `git status` now you'll see in green the difference between the index and what the new HEAD is.
177
177
@@ -186,7 +186,7 @@ This is also the default, so if you specify no option at all (just `git reset HE
186
186
Now take another second to look at that diagram and realize what happened: it still undid your last `commit`, but also _unstaged_ everything.
187
187
You rolled back to before you ran all your `git add` and `git commit` commands.
188
188
189
-
===== Step 3: Updating the Working Directory (--hard)
189
+
===== Step 3: Updating the Working Directory (`--hard`)
190
190
191
191
The third thing that `reset` will do is to make the working directory look like the index.
192
192
If you use the `--hard` option, it will continue to this stage.
@@ -271,8 +271,8 @@ And then simply run `git commit` again:
271
271
.Git repository with squashed commit
272
272
image::images/reset-squash-r3.png[Git repository with squashed commit]
273
273
274
-
Now you can see that your reachable history, the history you would push, now looks like you had one commit with `file-a.txt` v1, then a second that both modified `file-a.txt` to v3 and added `file-b.txt`.
275
-
The commit with the v2 version of the file is no longer in the history.
274
+
Now you can see that your reachable history, the history you would push, now looks like you had one commit with `file-a.txt` *v1*, then a second that both modified `file-a.txt` to *v3* and added `file-b.txt`.
275
+
The commit with the *v2* version of the file is no longer in the history.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/stashing-cleaning.asc
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,7 +114,7 @@ Changes not staged for commit:
114
114
modified: lib/simplegit.rb
115
115
----
116
116
117
-
The apply option only tries to apply the stashed work -- you continue to have it on your stack.
117
+
The `apply` option only tries to apply the stashed work -- you continue to have it on your stack.
118
118
To remove it, you can run `git stash drop` with the name of the stash to remove:
119
119
120
120
[source,console]
@@ -249,7 +249,7 @@ Would remove tmp/
249
249
250
250
By default, the `git clean` command will only remove untracked files that are not ignored.
251
251
Any file that matches a pattern in your `.gitignore` or other ignore files will not be removed.
252
-
If you want to remove those files too, such as to remove all `.o` files generated from a build so you can do a fully clean build, you can add a `-x` to the clean command.
252
+
If you want to remove those files too, such as to remove all `.o` files generated from a build so you can do a fully clean build, you can add a `-x` to the `clean` command.
253
253
254
254
[source,console]
255
255
----
@@ -271,7 +271,7 @@ Would remove tmp/
271
271
If you don't know what the `git clean` command is going to do, always run it with a `-n` first to double check before changing the `-n` to a `-f` and doing it for real.
272
272
The other way you can be careful about the process is to run it with the `-i` or "`interactive`" flag.
273
273
274
-
This will run the clean command in an interactive mode.
274
+
This will run the `clean` command in an interactive mode.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/submodules.asc
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -264,7 +264,7 @@ Submodule path 'DbConnector': checked out 'd0354fc054692d3906c85c3af05ddce39a1c0
264
264
265
265
This command will by default assume that you want to update the checkout to the default branch of the remote submodule repository (the one pointed to by `HEAD` on the remote).
266
266
You can, however, set this to something different if you want.
267
-
For example, if you want to have the DbConnector submodule track that repository's "`stable`" branch, you can set it in either your `.gitmodules` file (so everyone else also tracks it), or just in your local `.git/config` file.
267
+
For example, if you want to have the `DbConnector` submodule track that repository's "`stable`" branch, you can set it in either your `.gitmodules` file (so everyone else also tracks it), or just in your local `.git/config` file.
268
268
Let's set it in the `.gitmodules` file:
269
269
270
270
[source,console]
@@ -418,7 +418,7 @@ no changes added to commit (use "git add" and/or "git commit -a")
418
418
By default, the `git pull` command recursively fetches submodules changes, as we can see in the output of the first command above.
419
419
However, it does not *update* the submodules.
420
420
This is shown by the output of the `git status` command, which shows the submodule is "`modified`", and has "`new commits`".
421
-
What's more, the brackets showing the new commits point left (<), indicating that these commits are recorded in MainProject but are not present in the local DbConnector checkout.
421
+
What's more, the brackets showing the new commits point left (<), indicating that these commits are recorded in MainProject but are not present in the local `DbConnector` checkout.
422
422
To finalize the update, you need to run `git submodule update`:
423
423
424
424
[source,console]
@@ -436,7 +436,7 @@ Note that to be on the safe side, you should run `git submodule update` with the
436
436
437
437
If you want to automate this process, you can add the `--recurse-submodules` flag to the `git pull` command (since Git 2.14).
438
438
This will make Git run `git submodule update` right after the pull, putting the submodules in the correct state.
439
-
Moreover, if you want to make Git always pull with `--recurse-submodules`, you can set the configuration option `submodule.recurse` to true (this works for `git pull` since Git 2.15).
439
+
Moreover, if you want to make Git always pull with `--recurse-submodules`, you can set the configuration option `submodule.recurse` to `true` (this works for `git pull` since Git 2.15).
440
440
This option will make Git use the `--recurse-submodules` flag for all commands that support it (except `clone`).
441
441
442
442
There is a special situation that can happen when pulling superproject updates: it could be that the upstream repository has changed the URL of the submodule in the `.gitmodules` file in one of the commits you pull.
@@ -499,7 +499,7 @@ Fast-forward
499
499
Submodule path 'DbConnector': merged in '92c7337b30ef9e0893e758dac2459d07362ab5ea'
500
500
----
501
501
502
-
If we go into the DbConnector directory, we have the new changes already merged into our local `stable` branch.
502
+
If we go into the `DbConnector` directory, we have the new changes already merged into our local `stable` branch.
503
503
Now let's see what happens when we make our own local change to the library and someone else pushes another change to the upstream at the same time.
504
504
505
505
[source,console]
@@ -532,7 +532,7 @@ Submodule path 'DbConnector': checked out '5d60ef9bbebf5a0c1c1050f242ceeb54ad58d
532
532
533
533
If this happens, don't worry, you can simply go back into the directory and check out your branch again (which will still contain your work) and merge or rebase `origin/stable` (or whatever remote branch you want) manually.
534
534
535
-
If you haven't committed your changes in your submodule and you run a submodule update that would cause issues, Git will fetch the changes but not overwrite unsaved work in your submodule directory.
535
+
If you haven't committed your changes in your submodule and you run a `submodule update` that would cause issues, Git will fetch the changes but not overwrite unsaved work in your submodule directory.
536
536
537
537
[source,console]
538
538
----
@@ -632,7 +632,7 @@ To https://github.com/chaconinc/MainProject
632
632
3d6d338..9a377d1 master -> master
633
633
----
634
634
635
-
As you can see there, Git went into the DbConnector module and pushed it before pushing the main project.
635
+
As you can see there, Git went into the `DbConnector` module and pushed it before pushing the main project.
636
636
If that submodule push fails for some reason, the main project push will also fail.
637
637
You can make this behavior the default by doing `git config push.recurseSubmodules on-demand`.
0 commit comments