summaryrefslogtreecommitdiffstats
path: root/man7/gittutorial.7
diff options
context:
space:
mode:
Diffstat (limited to 'man7/gittutorial.7')
-rw-r--r--man7/gittutorial.7109
1 files changed, 55 insertions, 54 deletions
diff --git a/man7/gittutorial.7 b/man7/gittutorial.7
index 48bd8c37d..5bc274bb7 100644
--- a/man7/gittutorial.7
+++ b/man7/gittutorial.7
@@ -2,12 +2,12 @@
.\" Title: gittutorial
.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
-.\" Date: 2023-05-09
+.\" Date: 2023-05-10
.\" Manual: Git Manual
-.\" Source: Git 2.40.1.515.g5597cfdf47
+.\" Source: Git 2.40.1.552.g91428f078b
.\" Language: English
.\"
-.TH "GITTUTORIAL" "7" "2023\-05\-09" "Git 2\&.40\&.1\&.515\&.g5597cf" "Git Manual"
+.TH "GITTUTORIAL" "7" "2023\-05\-10" "Git 2\&.40\&.1\&.552\&.g91428f" "Git Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -84,7 +84,7 @@ $ git config \-\-global user\&.email you@yourdomain\&.example\&.com
.sp
.SH "IMPORTING A NEW PROJECT"
.sp
-Assume you have a tarball project\&.tar\&.gz with your initial work\&. You can place it under Git revision control as follows\&.
+Assume you have a tarball \fBproject\&.tar\&.gz\fR with your initial work\&. You can place it under Git revision control as follows\&.
.sp
.if n \{\
.RS 4
@@ -112,9 +112,9 @@ Initialized empty Git repository in \&.git/
.\}
.sp
.sp
-You\(cqve now initialized the working directory\(emyou may notice a new directory created, named "\&.git"\&.
+You\(cqve now initialized the working directory\(emyou may notice a new directory created, named \fB\&.git\fR\&.
.sp
-Next, tell Git to take a snapshot of the contents of all files under the current directory (note the \fI\&.\fR), with \fIgit add\fR:
+Next, tell Git to take a snapshot of the contents of all files under the current directory (note the \fB\&.\fR), with \fBgit add\fR:
.sp
.if n \{\
.RS 4
@@ -127,7 +127,7 @@ $ git add \&.
.\}
.sp
.sp
-This snapshot is now stored in a temporary staging area which Git calls the "index"\&. You can permanently store the contents of the index in the repository with \fIgit commit\fR:
+This snapshot is now stored in a temporary staging area which Git calls the "index"\&. You can permanently store the contents of the index in the repository with \fBgit commit\fR:
.sp
.if n \{\
.RS 4
@@ -156,7 +156,7 @@ $ git add file1 file2 file3
.\}
.sp
.sp
-You are now ready to commit\&. You can see what is about to be committed using \fIgit diff\fR with the \-\-cached option:
+You are now ready to commit\&. You can see what is about to be committed using \fBgit diff\fR with the \fB\-\-cached\fR option:
.sp
.if n \{\
.RS 4
@@ -169,7 +169,7 @@ $ git diff \-\-cached
.\}
.sp
.sp
-(Without \-\-cached, \fIgit diff\fR will show you any changes that you\(cqve made but not yet added to the index\&.) You can also get a brief summary of the situation with \fIgit status\fR:
+(Without \fB\-\-cached\fR, \fBgit diff\fR will show you any changes that you\(cqve made but not yet added to the index\&.) You can also get a brief summary of the situation with \fBgit status\fR:
.sp
.if n \{\
.RS 4
@@ -178,7 +178,6 @@ $ git diff \-\-cached
$ git status
On branch master
Changes to be committed:
-Your branch is up to date with \*(Aqorigin/master\*(Aq\&.
(use "git restore \-\-staged <file>\&.\&.\&." to unstage)
modified: file1
@@ -205,7 +204,7 @@ $ git commit
.sp
This will again prompt you for a message describing the change, and then record a new version of the project\&.
.sp
-Alternatively, instead of running \fIgit add\fR beforehand, you can use
+Alternatively, instead of running \fBgit add\fR beforehand, you can use
.sp
.if n \{\
.RS 4
@@ -223,7 +222,7 @@ which will automatically notice any modified (but not new) files, add them to th
A note on commit messages: Though not required, it\(cqs a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description\&. The text up to the first blank line in a commit message is treated as the commit title, and that title is used throughout Git\&. For example, \fBgit-format-patch\fR(1) turns a commit into email, and it uses the title on the Subject line and the rest of the commit in the body\&.
.SH "GIT TRACKS CONTENT NOT FILES"
.sp
-Many revision control systems provide an \fBadd\fR command that tells the system to start tracking changes to a new file\&. Git\(cqs \fBadd\fR command does something simpler and more powerful: \fIgit add\fR is used both for new and newly modified files, and in both cases it takes a snapshot of the given files and stages that content in the index, ready for inclusion in the next commit\&.
+Many revision control systems provide an \fBadd\fR command that tells the system to start tracking changes to a new file\&. Git\(cqs \fBadd\fR command does something simpler and more powerful: \fBgit add\fR is used both for new and newly modified files, and in both cases it takes a snapshot of the given files and stages that content in the index, ready for inclusion in the next commit\&.
.SH "VIEWING PROJECT HISTORY"
.sp
At any point you can view the history of your changes using
@@ -266,7 +265,7 @@ $ git log \-\-stat \-\-summary
.sp
.SH "MANAGING BRANCHES"
.sp
-A single Git repository can maintain multiple branches of development\&. To create a new branch named "experimental", use
+A single Git repository can maintain multiple branches of development\&. To create a new branch named \fBexperimental\fR, use
.sp
.if n \{\
.RS 4
@@ -306,7 +305,7 @@ you\(cqll get a list of all existing branches:
.\}
.sp
.sp
-The "experimental" branch is the one you just created, and the "master" branch is a default branch that was created for you automatically\&. The asterisk marks the branch you are currently on; type
+The \fBexperimental\fR branch is the one you just created, and the \fBmaster\fR branch is a default branch that was created for you automatically\&. The asterisk marks the branch you are currently on; type
.sp
.if n \{\
.RS 4
@@ -319,7 +318,7 @@ $ git switch experimental
.\}
.sp
.sp
-to switch to the experimental branch\&. Now edit a file, commit the change, and switch back to the master branch:
+to switch to the \fBexperimental\fR branch\&. Now edit a file, commit the change, and switch back to the \fBmaster\fR branch:
.sp
.if n \{\
.RS 4
@@ -334,9 +333,9 @@ $ git switch master
.\}
.sp
.sp
-Check that the change you made is no longer visible, since it was made on the experimental branch and you\(cqre back on the master branch\&.
+Check that the change you made is no longer visible, since it was made on the \fBexperimental\fR branch and you\(cqre back on the \fBmaster\fR branch\&.
.sp
-You can make a different change on the master branch:
+You can make a different change on the \fBmaster\fR branch:
.sp
.if n \{\
.RS 4
@@ -350,7 +349,7 @@ $ git commit \-a
.\}
.sp
.sp
-at this point the two branches have diverged, with different changes made in each\&. To merge the changes made in experimental into master, run
+at this point the two branches have diverged, with different changes made in each\&. To merge the changes made in \fBexperimental\fR into \fBmaster\fR, run
.sp
.if n \{\
.RS 4
@@ -404,7 +403,7 @@ $ gitk
.sp
will show a nice graphical representation of the resulting history\&.
.sp
-At this point you could delete the experimental branch with
+At this point you could delete the \fBexperimental\fR branch with
.sp
.if n \{\
.RS 4
@@ -417,9 +416,9 @@ $ git branch \-d experimental
.\}
.sp
.sp
-This command ensures that the changes in the experimental branch are already in the current branch\&.
+This command ensures that the changes in the \fBexperimental\fR branch are already in the current branch\&.
.sp
-If you develop on a branch crazy\-idea, then regret it, you can always delete the branch with
+If you develop on a branch \fBcrazy\-idea\fR, then regret it, you can always delete the branch with
.sp
.if n \{\
.RS 4
@@ -435,7 +434,7 @@ $ git branch \-D crazy\-idea
Branches are cheap and easy, so this is a good way to try something out\&.
.SH "USING GIT FOR COLLABORATION"
.sp
-Suppose that Alice has started a new project with a Git repository in /home/alice/project, and that Bob, who has a home directory on the same machine, wants to contribute\&.
+Suppose that Alice has started a new project with a Git repository in \fB/home/alice/project\fR, and that Bob, who has a home directory on the same machine, wants to contribute\&.
.sp
Bob begins with:
.sp
@@ -450,7 +449,7 @@ bob$ git clone /home/alice/project myrepo
.\}
.sp
.sp
-This creates a new directory "myrepo" containing a clone of Alice\(cqs repository\&. The clone is on an equal footing with the original project, possessing its own copy of the original project\(cqs history\&.
+This creates a new directory \fBmyrepo\fR containing a clone of Alice\(cqs repository\&. The clone is on an equal footing with the original project, possessing its own copy of the original project\(cqs history\&.
.sp
Bob then makes some changes and commits them:
.sp
@@ -467,7 +466,7 @@ bob$ git commit \-a
.\}
.sp
.sp
-When he\(cqs ready, he tells Alice to pull changes from the repository at /home/bob/myrepo\&. She does this with:
+When he\(cqs ready, he tells Alice to pull changes from the repository at \fB/home/bob/myrepo\fR\&. She does this with:
.sp
.if n \{\
.RS 4
@@ -481,13 +480,13 @@ alice$ git pull /home/bob/myrepo master
.\}
.sp
.sp
-This merges the changes from Bob\(cqs "master" branch into Alice\(cqs current branch\&. If Alice has made her own changes in the meantime, then she may need to manually fix any conflicts\&.
+This merges the changes from Bob\(cqs \fBmaster\fR branch into Alice\(cqs current branch\&. If Alice has made her own changes in the meantime, then she may need to manually fix any conflicts\&.
.sp
-The "pull" command thus performs two operations: it fetches changes from a remote branch, then merges them into the current branch\&.
+The \fBpull\fR command thus performs two operations: it fetches changes from a remote branch, then merges them into the current branch\&.
.sp
-Note that in general, Alice would want her local changes committed before initiating this "pull"\&. If Bob\(cqs work conflicts with what Alice did since their histories forked, Alice will use her working tree and the index to resolve conflicts, and existing local changes will interfere with the conflict resolution process (Git will still perform the fetch but will refuse to merge \(em Alice will have to get rid of her local changes in some way and pull again when this happens)\&.
+Note that in general, Alice would want her local changes committed before initiating this \fBpull\fR\&. If Bob\(cqs work conflicts with what Alice did since their histories forked, Alice will use her working tree and the index to resolve conflicts, and existing local changes will interfere with the conflict resolution process (Git will still perform the fetch but will refuse to merge \(em Alice will have to get rid of her local changes in some way and pull again when this happens)\&.
.sp
-Alice can peek at what Bob did without merging first, using the "fetch" command; this allows Alice to inspect what Bob did, using a special symbol "FETCH_HEAD", in order to determine if he has anything worth pulling, like this:
+Alice can peek at what Bob did without merging first, using the \fBfetch\fR command; this allows Alice to inspect what Bob did, using a special symbol \fBFETCH_HEAD\fR, in order to determine if he has anything worth pulling, like this:
.sp
.if n \{\
.RS 4
@@ -501,7 +500,7 @@ alice$ git log \-p HEAD\&.\&.FETCH_HEAD
.\}
.sp
.sp
-This operation is safe even if Alice has uncommitted local changes\&. The range notation "HEAD\&.\&.FETCH_HEAD" means "show everything that is reachable from the FETCH_HEAD but exclude anything that is reachable from HEAD"\&. Alice already knows everything that leads to her current state (HEAD), and reviews what Bob has in his state (FETCH_HEAD) that she has not seen with this command\&.
+This operation is safe even if Alice has uncommitted local changes\&. The range notation \fBHEAD\&.\&.FETCH_HEAD\fR means "show everything that is reachable from the \fBFETCH_HEAD\fR but exclude anything that is reachable from \fBHEAD\fR"\&. Alice already knows everything that leads to her current state (\fBHEAD\fR), and reviews what Bob has in his state (\fBFETCH_HEAD\fR) that she has not seen with this command\&.
.sp
If Alice wants to visualize what Bob did since their histories forked she can issue the following command:
.sp
@@ -516,7 +515,7 @@ $ gitk HEAD\&.\&.FETCH_HEAD
.\}
.sp
.sp
-This uses the same two\-dot range notation we saw earlier with \fIgit log\fR\&.
+This uses the same two\-dot range notation we saw earlier with \fBgit log\fR\&.
.sp
Alice may want to view what both of them did since they forked\&. She can use three\-dot form instead of the two\-dot form:
.sp
@@ -533,9 +532,9 @@ $ gitk HEAD\&.\&.\&.FETCH_HEAD
.sp
This means "show everything that is reachable from either one, but exclude anything that is reachable from both of them"\&.
.sp
-Please note that these range notation can be used with both gitk and "git log"\&.
+Please note that these range notation can be used with both \fBgitk\fR and \fBgit log\fR\&.
.sp
-After inspecting what Bob did, if there is nothing urgent, Alice may decide to continue working without pulling from Bob\&. If Bob\(cqs history does have something Alice would immediately need, Alice may choose to stash her work\-in\-progress first, do a "pull", and then finally unstash her work\-in\-progress on top of the resulting history\&.
+After inspecting what Bob did, if there is nothing urgent, Alice may decide to continue working without pulling from Bob\&. If Bob\(cqs history does have something Alice would immediately need, Alice may choose to stash her work\-in\-progress first, do a \fBpull\fR, and then finally unstash her work\-in\-progress on top of the resulting history\&.
.sp
When you are working in a small closely knit group, it is not unusual to interact with the same repository over and over again\&. By defining \fIremote\fR repository shorthand, you can make it easier:
.sp
@@ -550,7 +549,7 @@ alice$ git remote add bob /home/bob/myrepo
.\}
.sp
.sp
-With this, Alice can perform the first part of the "pull" operation alone using the \fIgit fetch\fR command without merging them with her own branch, using:
+With this, Alice can perform the first part of the \fBpull\fR operation alone using the \fBgit fetch\fR command without merging them with her own branch, using:
.sp
.if n \{\
.RS 4
@@ -563,7 +562,7 @@ alice$ git fetch bob
.\}
.sp
.sp
-Unlike the longhand form, when Alice fetches from Bob using a remote repository shorthand set up with \fIgit remote\fR, what was fetched is stored in a remote\-tracking branch, in this case \fBbob/master\fR\&. So after this:
+Unlike the longhand form, when Alice fetches from Bob using a remote repository shorthand set up with \fBgit remote\fR, what was fetched is stored in a remote\-tracking branch, in this case \fBbob/master\fR\&. So after this:
.sp
.if n \{\
.RS 4
@@ -576,9 +575,9 @@ alice$ git log \-p master\&.\&.bob/master
.\}
.sp
.sp
-shows a list of all the changes that Bob made since he branched from Alice\(cqs master branch\&.
+shows a list of all the changes that Bob made since he branched from Alice\(cqs \fBmaster\fR branch\&.
.sp
-After examining those changes, Alice could merge the changes into her master branch:
+After examining those changes, Alice could merge the changes into her \fBmaster\fR branch:
.sp
.if n \{\
.RS 4
@@ -633,9 +632,9 @@ bob$ git config \-\-get remote\&.origin\&.url
.\}
.sp
.sp
-(The complete configuration created by \fIgit clone\fR is visible using \fBgit config \-l\fR, and the \fBgit-config\fR(1) man page explains the meaning of each option\&.)
+(The complete configuration created by \fBgit clone\fR is visible using \fBgit config \-l\fR, and the \fBgit-config\fR(1) man page explains the meaning of each option\&.)
.sp
-Git also keeps a pristine copy of Alice\(cqs master branch under the name "origin/master":
+Git also keeps a pristine copy of Alice\(cqs \fBmaster\fR branch under the name \fBorigin/master\fR:
.sp
.if n \{\
.RS 4
@@ -667,7 +666,7 @@ Alternatively, Git has a native protocol, or can use http; see \fBgit-pull\fR(1)
Git can also be used in a CVS\-like mode, with a central repository that various users push changes to; see \fBgit-push\fR(1) and \fBgitcvs-migration\fR(7)\&.
.SH "EXPLORING HISTORY"
.sp
-Git history is represented as a series of interrelated commits\&. We have already seen that the \fIgit log\fR command can list those commits\&. Note that first line of each git log entry also gives a name for the commit:
+Git history is represented as a series of interrelated commits\&. We have already seen that the \fBgit log\fR command can list those commits\&. Note that first line of each \fBgit log\fR entry also gives a name for the commit:
.sp
.if n \{\
.RS 4
@@ -685,7 +684,7 @@ Date: Tue May 16 17:18:22 2006 \-0700
.\}
.sp
.sp
-We can give this name to \fIgit show\fR to see the details about this commit\&.
+We can give this name to \fBgit show\fR to see the details about this commit\&.
.sp
.if n \{\
.RS 4
@@ -756,7 +755,7 @@ $ git tag v2\&.5 1b2e1d63ff
.\}
.sp
.sp
-you can refer to 1b2e1d63ff by the name "v2\&.5"\&. If you intend to share this name with other people (for example, to identify a release version), you should create a "tag" object, and perhaps sign it; see \fBgit-tag\fR(1) for details\&.
+you can refer to \fB1b2e1d63ff\fR by the name \fBv2\&.5\fR\&. If you intend to share this name with other people (for example, to identify a release version), you should create a "tag" object, and perhaps sign it; see \fBgit-tag\fR(1) for details\&.
.sp
Any Git command that needs to know a commit can take any of these names\&. For example:
.sp
@@ -775,9 +774,9 @@ $ git reset \-\-hard HEAD^ # reset your current branch and working
.\}
.sp
.sp
-Be careful with that last command: in addition to losing any changes in the working directory, it will also remove all later commits from this branch\&. If this branch is the only branch containing those commits, they will be lost\&. Also, don\(cqt use \fIgit reset\fR on a publicly\-visible branch that other developers pull from, as it will force needless merges on other developers to clean up the history\&. If you need to undo changes that you have pushed, use \fIgit revert\fR instead\&.
+Be careful with that last command: in addition to losing any changes in the working directory, it will also remove all later commits from this branch\&. If this branch is the only branch containing those commits, they will be lost\&. Also, don\(cqt use \fBgit reset\fR on a publicly\-visible branch that other developers pull from, as it will force needless merges on other developers to clean up the history\&. If you need to undo changes that you have pushed, use \fBgit revert\fR instead\&.
.sp
-The \fIgit grep\fR command can search for strings in any version of your project, so
+The \fBgit grep\fR command can search for strings in any version of your project, so
.sp
.if n \{\
.RS 4
@@ -790,9 +789,9 @@ $ git grep "hello" v2\&.5
.\}
.sp
.sp
-searches for all occurrences of "hello" in v2\&.5\&.
+searches for all occurrences of "hello" in \fBv2\&.5\fR\&.
.sp
-If you leave out the commit name, \fIgit grep\fR will search any of the files it manages in your current directory\&. So
+If you leave out the commit name, \fBgit grep\fR will search any of the files it manages in your current directory\&. So
.sp
.if n \{\
.RS 4
@@ -807,7 +806,7 @@ $ git grep "hello"
.sp
is a quick way to search just the files that are tracked by Git\&.
.sp
-Many Git commands also take sets of commits, which can be specified in a number of ways\&. Here are some examples with \fIgit log\fR:
+Many Git commands also take sets of commits, which can be specified in a number of ways\&. Here are some examples with \fBgit log\fR:
.sp
.if n \{\
.RS 4
@@ -824,7 +823,7 @@ $ git log v2\&.5\&.\&. Makefile # commits since v2\&.5 which modify
.\}
.sp
.sp
-You can also give \fIgit log\fR a "range" of commits where the first is not necessarily an ancestor of the second; for example, if the tips of the branches "stable" and "master" diverged from a common commit some time ago, then
+You can also give \fBgit log\fR a "range" of commits where the first is not necessarily an ancestor of the second; for example, if the tips of the branches \fBstable\fR and \fBmaster\fR diverged from a common commit some time ago, then
.sp
.if n \{\
.RS 4
@@ -837,7 +836,7 @@ $ git log stable\&.\&.master
.\}
.sp
.sp
-will list commits made in the master branch but not in the stable branch, while
+will list commits made in the \fBmaster\fR branch but not in the stable branch, while
.sp
.if n \{\
.RS 4
@@ -850,11 +849,11 @@ $ git log master\&.\&.stable
.\}
.sp
.sp
-will show the list of commits made on the stable branch but not the master branch\&.
+will show the list of commits made on the stable branch but not the \fBmaster\fR branch\&.
.sp
-The \fIgit log\fR command has a weakness: it must present commits in a list\&. When the history has lines of development that diverged and then merged back together, the order in which \fIgit log\fR presents those commits is meaningless\&.
+The \fBgit log\fR command has a weakness: it must present commits in a list\&. When the history has lines of development that diverged and then merged back together, the order in which \fBgit log\fR presents those commits is meaningless\&.
.sp
-Most projects with multiple contributors (such as the Linux kernel, or Git itself) have frequent merges, and \fIgitk\fR does a better job of visualizing their history\&. For example,
+Most projects with multiple contributors (such as the Linux kernel, or Git itself) have frequent merges, and \fBgitk\fR does a better job of visualizing their history\&. For example,
.sp
.if n \{\
.RS 4
@@ -867,7 +866,7 @@ $ gitk \-\-since="2 weeks ago" drivers/
.\}
.sp
.sp
-allows you to browse any commits from the last 2 weeks of commits that modified files under the "drivers" directory\&. (Note: you can adjust gitk\(cqs fonts by holding down the control key while pressing "\-" or "+"\&.)
+allows you to browse any commits from the last 2 weeks of commits that modified files under the \fBdrivers\fR directory\&. (Note: you can adjust gitk\(cqs fonts by holding down the control key while pressing "\-" or "+"\&.)
.sp
Finally, most commands that take filenames will optionally allow you to precede any filename by a commit, to specify a particular version of the file:
.sp
@@ -882,7 +881,7 @@ $ git diff v2\&.5:Makefile HEAD:Makefile\&.in
.\}
.sp
.sp
-You can also use \fIgit show\fR to see any such file:
+You can also use \fBgit show\fR to see any such file:
.sp
.if n \{\
.RS 4
@@ -944,7 +943,9 @@ If you don\(cqt want to continue with that right away, a few other digressions t
.sp -1
.IP \(bu 2.3
.\}
-\fBgit-bisect\fR(1): When there is a regression in your project, one way to track down the bug is by searching through the history to find the exact commit that\(cqs to blame\&. Git bisect can help you perform a binary search for that commit\&. It is smart enough to perform a close\-to\-optimal search even in the case of complex non\-linear history with lots of merged branches\&.
+\fBgit-bisect\fR(1): When there is a regression in your project, one way to track down the bug is by searching through the history to find the exact commit that\(cqs to blame\&.
+\fBgit bisect\fR
+can help you perform a binary search for that commit\&. It is smart enough to perform a close\-to\-optimal search even in the case of complex non\-linear history with lots of merged branches\&.
.RE
.sp
.RS 4