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/02-git-basics/sections/recording-changes.asc
+7
Original file line number
Diff line number
Diff line change
@@ -360,6 +360,13 @@ index 3cb747f..e445e28 100644
360
360
log.size
361
361
----
362
362
363
+
[[_git_difftool]]
364
+
[NOTE]
365
+
.Git Diff in an External Tool
366
+
====
367
+
We will continue to use the `git diff` command in various ways throughout the rest of the book. There is another way to look at these diffs if you prefer a graphical or external diff viewing program instead. If you run `git difftool` instead of `git diff`, you can view any of these diffs in software like Araxis, emerge, vimdiff and more. Run `git difftool --tool-help` to see what is available on your system.
Copy file name to clipboardExpand all lines: book/02-git-basics/sections/remotes.asc
+4-1
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
[[_remote_repos]]
1
2
=== Working with Remotes
2
3
3
4
To be able to collaborate on any Git project, you need to know how to manage your remote repositories.
@@ -94,7 +95,7 @@ From https://github.com/paulboone/ticgit
94
95
Paul's master branch is now accessible locally as `pb/master` – you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it.
95
96
(We'll go over what branches are and how to use them in much more detail in <<_git_branching>>.)
96
97
97
-
98
+
[[_fetching_and_pulling]]
98
99
==== Fetching and Pulling from Your Remotes
99
100
100
101
As you just saw, to get data from your remote projects, you can run:(((git commands, fetch)))
@@ -116,6 +117,7 @@ If you have a branch set up to track a remote branch (see the next section and <
116
117
This may be an easier or more comfortable workflow for you; and by default, the `git clone` command automatically sets up your local master branch to track the remote master branch (or whatever the default branch is called) on the server you cloned from.
117
118
Running `git pull` generally fetches data from the server you originally cloned from and automatically tries to merge it into the code you're currently working on.
118
119
120
+
[[_pushing_remotes]]
119
121
==== Pushing to Your Remotes
120
122
121
123
When you have your project at a point that you want to share, you have to push it upstream.
@@ -132,6 +134,7 @@ If you and someone else clone at the same time and they push upstream and then y
132
134
You'll have to pull down their work first and incorporate it into yours before you'll be allowed to push.
133
135
See <<_git_branching>> for more detailed information on how to push to remote servers.
134
136
137
+
[[_inspecting_remote]]
135
138
==== Inspecting a Remote
136
139
137
140
If you want to see more information about a particular remote, you can use the `git remote show [remote-name]` command.(((git commands, remote)))
Copy file name to clipboardExpand all lines: book/02-git-basics/sections/tagging.asc
+3
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
[[_git_tagging]]
1
2
=== Tagging
2
3
3
4
(((tags)))
@@ -48,6 +49,7 @@ Annotated tags, however, are stored as full objects in the Git database.
48
49
They're checksummed; contain the tagger name, e-mail, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG).
49
50
It's generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don't want to keep the other information, lightweight tags are available too.
Copy file name to clipboardExpand all lines: book/02-git-basics/sections/undoing.asc
+1-1
Original file line number
Diff line number
Diff line change
@@ -126,5 +126,5 @@ Don't ever use this command unless you absolutely know that you don't want the f
126
126
If you would like to keep the changes you've made to that file but still need to get it out of the way for now, we'll go over stashing and branching in <<_git_branching>>; these are generally better ways to go.
127
127
128
128
Remember, anything that is __committed__ in Git can almost always be recovered.
129
-
Even commits that were on branches that were deleted or commits that were overwritten with an `--amend` commit can be recovered (see <<data_recovery>> for data recovery).
129
+
Even commits that were on branches that were deleted or commits that were overwritten with an `--amend` commit can be recovered (see <<_data_recovery>> for data recovery).
130
130
However, anything you lose that was never committed is likely never to be seen again.
Copy file name to clipboardExpand all lines: book/02-git-basics/sections/viewing-history.asc
+1
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
[[_viewing_history]]
1
2
=== Viewing the Commit History
2
3
3
4
After you have created several commits, or if you have cloned a repository with an existing commit history, you'll probably want to look back to see what has happened.
Copy file name to clipboardExpand all lines: book/03-git-branching/sections/rebasing.asc
+1
Original file line number
Diff line number
Diff line change
@@ -170,6 +170,7 @@ If you run a `git log` when your history looks like this, you'll see two commits
170
170
Furthermore, if you push this history back up to the server, you'll reintroduce all those rebased commits to the central server, which can further confuse people.
171
171
It's pretty safe to assume that the other developer doesn't want `C4` and `C6` to be in the history; that's why she rebased in the first place.
172
172
173
+
[[_rebase_rebase]]
173
174
==== Rebase when you Rebase
174
175
175
176
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.
Copy file name to clipboardExpand all lines: book/05-distributed-git/sections/contributing.asc
+3
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
[[_contributing_project]]
1
2
=== Contributing to a Project
2
3
3
4
(((contributing)))
@@ -89,6 +90,7 @@ The Git project has well-formatted commit messages – try running `git log --no
89
90
In the following examples, and throughout most of this book, for the sake of brevity this book doesn't have nicely-formatted messages like this; instead, we use the `-m` option to `git commit`.
90
91
Do as we say, not as we do.
91
92
93
+
[[_private_team]]
92
94
==== Private Small Team
93
95
94
96
(((contributing, private small team)))
@@ -613,6 +615,7 @@ Now you can send the maintainer a message that you've made the requested changes
613
615
.Commit history after `featureBv2` work.
614
616
image::images/public-small-3.png[Commit history after `featureBv2` work.]
Now you're ready to add your contributed work into this topic branch and determine if you want to merge it into your longer-term branches.
30
30
31
+
[[_patches_from_email]]
31
32
==== Applying Patches from E-mail
32
33
33
34
(((email, applying patches from)))
@@ -64,6 +65,7 @@ error: ticgit.gemspec: patch does not apply
64
65
If there is no output, then the patch should apply cleanly.
65
66
This command also exits with a non-zero status if the check fails, so you can use it in scripts if you want.
66
67
68
+
[[_git_am]]
67
69
===== Applying a Patch with `am`
68
70
69
71
(((git commands, am)))
@@ -353,6 +355,7 @@ When a topic branch has finally been merged into `master`, it's removed from the
353
355
The Git project also has a `maint` branch that is forked off from the last release to provide backported patches in case a maintenance release is required.
354
356
Thus, when you clone the Git repository, you have four branches that you can check out to evaluate the project in different stages of development, depending on how cutting edge you want to be or how you want to contribute; and the maintainer has a structured workflow to help them vet new contributions.
355
357
358
+
[[_rebase_cherry_pick]]
356
359
===== Rebasing and Cherry Picking Workflows
357
360
358
361
(((workflows, rebasing and cherry-picking)))
@@ -410,6 +413,7 @@ If you need to, you can interact with the rerere cache using the `git rerere` co
410
413
When it's invoked alone, Git checks its database of resolutions and tries to find a match with any current merge conflicts and resolve them (although this is done automatically if `rerere.enabled` is set to `true`).
411
414
There are also subcommands to see what will be recorded, to erase specific resolution from the cache, and to clear the entire cache. We will cover rerere in more detail in <<_rerere>>.
They can use that key to verify all your signed tags.
466
470
Also, if you include instructions in the tag message, running `git show <tag>` will let you give the end user more specific instructions about tag verification.
467
471
472
+
[[_build_number]]
468
473
==== Generating a Build Number
469
474
470
475
(((build numbers)))(((git commands, describe)))
@@ -485,6 +490,7 @@ The `git describe` command favors annotated tags (tags created with the `-a` or
485
490
You can also use this string as the target of a checkout or show command, although it relies on the abbreviated SHA-1 value at the end, so it may not be valid forever.
486
491
For instance, the Linux kernel recently jumped from 8 to 10 characters to ensure SHA-1 object uniqueness, so older `git describe` output names were invalidated.
Copy file name to clipboardExpand all lines: book/06-github/sections/3-maintaining.asc
+2
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,7 @@ Pull Requests can either come from a branch in a fork of your repository or they
62
62
63
63
For these examples, let's assume you are ``tonychacon'' and you've created a new Arudino code project named ``fade''.
64
64
65
+
[[_email_notifications]]
65
66
===== Email Notifications
66
67
67
68
Someone comes along and makes a change to your code and sends you a Pull Request. You should get an email notifying you about the new Pull Request and it should look something like <<_email_pr>>.
If you decide you don't want to merge it, you can also just close the Pull Request and the person who opened it will be notified.
102
103
104
+
[[_pr_refs]]
103
105
===== Pull Request Refs
104
106
105
107
If you're dealing with a *lot* of Pull Requests and don't want to add a bunch of remotes or do one time pulls every time, there is a neat trick that GitHub allows you to do. This is a bit of an advanced trick and we'll go over the details of this a bit more in <<_refspec>>, but it can be pretty useful.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/advanced-merging.asc
+3
Original file line number
Diff line number
Diff line change
@@ -136,6 +136,7 @@ Since in this case, the actual file changes were not conflicting, once we ignore
136
136
137
137
This is a lifesaver if you have someone on your team who likes to occasionally reformat everything from spaces to tabs or vice-versa.
138
138
139
+
[[_manual_remerge]]
139
140
===== Manual File Re-merging
140
141
141
142
Though Git handles whitespace pre-processing pretty well, there are other types of changes that perhaps Git can't handle automatically, but are scriptable fixes. As an example, let's pretend that Git could not handle the whitespace change and we needed to do it by hand.
@@ -362,6 +363,7 @@ The `git checkout` command can also take `--ours` and `--theirs` options, which
362
363
363
364
This can be particularly useful for conflicts of binary files where you can simply choose one side, or where you only want to merge certain files in from another branch - you can do the merge and then checkout certain files from one side or the other before committing.
364
365
366
+
[[_merge_log]]
365
367
===== Merge Log
366
368
367
369
Another useful tool when resolving merge conflicts is `git log`. This can help you get context on what may have contributed to the conflicts. Reviewing a little bit of history to remember why two lines of development were touching the same area of code can be really helpful sometimes.
@@ -512,6 +514,7 @@ The downside of this approach is that it's rewriting history, which can be probl
512
514
Check out <<_rebase_peril>> for more on what can happen; the short version is that if other people have the commits you're rewriting, you should probably avoid `reset`.
513
515
This approach also won't work if any other commits have been created since the merge; moving the refs would effectively lose those changes.
514
516
517
+
[[_reverse_commit]]
515
518
===== Reverse the commit
516
519
517
520
If moving the branch pointers around isn't going to work for you, Git gives you the option of making a new commit which undoes all the changes from an existing one.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/debugging.asc
+2
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
Git also provides a couple of tools to help you debug issues in your projects.
4
4
Because Git is designed to work with nearly any type of project, these tools are pretty generic, but they can often help you hunt for a bug or culprit when things go wrong.
5
5
6
+
[[_file_annotation]]
6
7
==== File Annotation
7
8
8
9
If you track down a bug in your code and want to know when it was introduced and why, file annotation is often your best tool.
@@ -62,6 +63,7 @@ This is really useful.
62
63
Normally, you get as the original commit the commit where you copied the code over, because that is the first time you touched those lines in this file.
63
64
Git tells you the original commit where you wrote those lines, even if it was in another file.
64
65
66
+
[[_binary_search]]
65
67
==== Binary Search
66
68
67
69
Annotating a file helps if you know where the issue is to begin with.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/notes.asc
+3
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
[[_git_notes]]
1
2
=== Notes
2
3
3
4
One of the cool things about Git is that it has strong cryptographic integrity. If you change any bit in the commit data or any of the files it keeps, all the checksums change, including the commit SHA and every commit SHA since that one. However, that means that in order to amend the commit in any way, for instance to add some comments on something or even sign off on a commit, you have to change the SHA of the commit itself.
@@ -132,6 +133,7 @@ You can also switch the current namespace you're using so that the default for w
132
133
$ git config core.notesRef refs/notes/bugzilla
133
134
----
134
135
136
+
[[_sharing_notes]]
135
137
=== Sharing Notes
136
138
137
139
The notes (as you may have noticed in the previous section) are stored as references, just like branches and tags. This means you can push them to a server. However, Git has a bit of magic built in to expand a branch name like `master` to it's full name, which is `refs/heads/master`. Unfortunately, Git has no such magic built in for notes. So to push your notes to a server you cannot simply run something like `git push origin bugzilla`. Git will do
@@ -160,6 +162,7 @@ To https://github.com/schacon/kidgloves
160
162
161
163
In fact, you may want to just make that `git push origin refs/notes/*` which will push all your notes. This is what Git does normally for something like tags. When you run `git push origin --tags` it basically expands to `git push origin refs/tags/*`.
162
164
165
+
[[_getting_notes]]
163
166
==== Getting Notes
164
167
165
168
Unfortunately, getting notes is even more difficult. Notes do not come down with a clone and there nothing like `git fetch --notes`. In order to fetch notes, you have to specify both sides of the refspec.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/reset.asc
+1
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,7 @@ $ git ls-tree -r HEAD
48
48
49
49
The `cat-file` and `ls-tree` commands are ``plumbing'' commands that are used for lower level things and not really used in day-to-day work, but they help us see what's going on here.
50
50
51
+
[[_the_index]]
51
52
===== The Index
52
53
53
54
The Index is your *proposed next commit*. We've also been referring to this concept as Git's ``Staging Area'' as this is what Git looks at when you run `git commit`.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/revision-selection.asc
+3
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
[[_revision_selection]]
1
2
=== Revision Selection
2
3
3
4
Git allows you to specify specific commits or a range of commits in several ways.
@@ -81,6 +82,7 @@ If all 6.5 billion humans on Earth were programming, and every second, each one
81
82
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.
82
83
====
83
84
85
+
[[_branch_references]]
84
86
==== Branch References
85
87
86
88
The most straightforward way to specify a commit requires that it have a branch reference pointed at it.
@@ -104,6 +106,7 @@ $ git rev-parse topic1
104
106
ca82a6dff817ec66f44342007202690a93763949
105
107
----
106
108
109
+
[[_git_reflog]]
107
110
==== RefLog Shortnames
108
111
109
112
One of the things Git does in the background while you’re working away is keep a ``reflog'' – a log of where your HEAD and branch references have been for the last few months.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/searching.asc
+1
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
4
4
With just about any size codebase, you'll often need to find where a function is called or defined, or find the history of a method. Git provides a couple of useful tools for looking through the code and commits stored in it's database quickly and easily. We'll go through a few of them.
5
5
6
+
[[_git_grep]]
6
7
==== Git Grep
7
8
8
9
Git ships with a command called `grep` that allows you to easily search through any committed tree or the working directory for a string or regular expression. For these examples, we'll look through the Git source code itself.
This is a nice shortcut to recover stashed work easily and work on it in a new branch.
235
235
236
+
[[_git_clean]]
236
237
==== Cleaning your Working Directory
237
238
238
239
Finally, you may not want to stash some work or files in your working directory, but simply get rid of them. The `git clean` command will do this for you.
Copy file name to clipboardExpand all lines: book/07-git-tools/sections/submodules.asc
+1
Original file line number
Diff line number
Diff line change
@@ -451,6 +451,7 @@ Unable to merge 'c75e92a2b3855c9e5b66f915308390d9db204aca' in submodule path 'Db
451
451
452
452
You can go into the submodule directory and fix the conflict just as you normally would.
453
453
454
+
[[_publishing_submodules]]
454
455
===== Publishing Submodule Changes
455
456
456
457
Now we have some changes in our submodule directory. Some of these were brought in from upstream by our updates and others were made locally and aren't available to anyone else yet as we haven't pushed them yet.
0 commit comments