@ -44,7 +44,7 @@ to import into git.
For our first example, we're going to start a totally new repository from
For our first example, we're going to start a totally new repository from
scratch, with no pre-existing files, and we'll call it 'git-tutorial'.
scratch, with no pre-existing files, and we'll call it 'git-tutorial'.
To start up, create a subdirectory for it, change into that
To start up, create a subdirectory for it, change into that
subdirectory, and initialize the git infrastructure with 'git-init':
subdirectory, and initialize the git infrastructure with 'git init':
------------------------------------------------
------------------------------------------------
$ mkdir git-tutorial
$ mkdir git-tutorial
@ -139,7 +139,7 @@ but to actually check in your hard work, you will have to go through two steps:
- commit that index file as an object.
- commit that index file as an object.
The first step is trivial: when you want to tell git about any changes
The first step is trivial: when you want to tell git about any changes
to your working tree, you use the 'git-update-index' program. That
to your working tree, you use the 'git update-index' program. That
program normally just takes a list of filenames you want to update, but
program normally just takes a list of filenames you want to update, but
to avoid trivial mistakes, it refuses to add new entries to the index
to avoid trivial mistakes, it refuses to add new entries to the index
(or remove existing ones) unless you explicitly tell it that you're
(or remove existing ones) unless you explicitly tell it that you're
@ -173,14 +173,14 @@ and see two files:
which correspond with the objects with names of `557db...` and
which correspond with the objects with names of `557db...` and
`f24c7...` respectively.
`f24c7...` respectively.
If you want to, you can use 'git-cat-file' to look at those objects, but
If you want to, you can use 'git cat-file' to look at those objects, but
you'll have to use the object name, not the filename of the object:
you'll have to use the object name, not the filename of the object:
----------------
----------------
$ git cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238
$ git cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238
----------------
----------------
where the `-t` tells 'git-cat-file' to tell you what the "type" of the
where the `-t` tells 'git cat-file' to tell you what the "type" of the
object is. git will tell you that you have a "blob" object (i.e., just a
object is. git will tell you that you have a "blob" object (i.e., just a
regular file), and you can see the contents with
regular file), and you can see the contents with
@ -205,7 +205,7 @@ hexadecimal digits in most places.
Anyway, as we mentioned previously, you normally never actually take a
Anyway, as we mentioned previously, you normally never actually take a
look at the objects themselves, and typing long 40-character hex
look at the objects themselves, and typing long 40-character hex
names is not something you'd normally want to do. The above digression
names is not something you'd normally want to do. The above digression
was just to show that 'git-update-index' did something magical, and
was just to show that 'git update-index' did something magical, and
actually saved away the contents of your files into the git object
actually saved away the contents of your files into the git object
database.
database.
@ -228,7 +228,7 @@ $ echo "It's a new day for git" >>hello
and you can now, since you told git about the previous state of `hello`, ask
and you can now, since you told git about the previous state of `hello`, ask
git what has changed in the tree compared to your old index, using the
git what has changed in the tree compared to your old index, using the
'git-diff-files' command:
'git diff-files' command:
------------
------------
$ git diff-files
$ git diff-files
@ -239,7 +239,7 @@ version of a 'diff', but that internal version really just tells you
that it has noticed that "hello" has been modified, and that the old object
that it has noticed that "hello" has been modified, and that the old object
contents it had have been replaced with something else.
contents it had have been replaced with something else.
To make it readable, we can tell 'git-diff-files' to output the
To make it readable, we can tell 'git diff-files' to output the
differences as a patch, using the `-p` flag:
differences as a patch, using the `-p` flag:
------------
------------
@ -255,7 +255,7 @@ index 557db03..263414f 100644
i.e. the diff of the change we caused by adding another line to `hello`.
i.e. the diff of the change we caused by adding another line to `hello`.
In other words, 'git-diff-files' always shows us the difference between
In other words, 'git diff-files' always shows us the difference between
what is recorded in the index, and what is currently in the working
what is recorded in the index, and what is currently in the working
tree. That's very useful.
tree. That's very useful.
@ -283,7 +283,7 @@ that in two phases: creating a 'tree' object, and committing that 'tree'
object as a 'commit' object together with an explanation of what the
object as a 'commit' object together with an explanation of what the
tree was all about, along with information of how we came to that state.
tree was all about, along with information of how we came to that state.
Creating a tree object is trivial, and is done with 'git-write-tree'.
Creating a tree object is trivial, and is done with 'git write-tree'.
There are no options or other input: `git write-tree` will take the
There are no options or other input: `git write-tree` will take the
current index state, and write an object that describes that whole
current index state, and write an object that describes that whole
index. In other words, we're now tying together all the different
index. In other words, we're now tying together all the different
@ -307,23 +307,23 @@ is not a "blob" object, but a "tree" object (you can also use
`git cat-file` to actually output the raw object contents, but you'll see
`git cat-file` to actually output the raw object contents, but you'll see
mainly a binary mess, so that's less interesting).
mainly a binary mess, so that's less interesting).
However -- normally you'd never use 'git-write-tree' on its own, because
However -- normally you'd never use 'git write-tree' on its own, because
normally you always commit a tree into a commit object using the
normally you always commit a tree into a commit object using the
'git-commit-tree' command. In fact, it's easier to not actually use
'git commit-tree' command. In fact, it's easier to not actually use
'git-write-tree' on its own at all, but to just pass its result in as an
'git write-tree' on its own at all, but to just pass its result in as an
argument to 'git-commit-tree'.
argument to 'git commit-tree'.
'git-commit-tree' normally takes several arguments -- it wants to know
'git commit-tree' normally takes several arguments -- it wants to know
what the 'parent' of a commit was, but since this is the first commit
what the 'parent' of a commit was, but since this is the first commit
ever in this new repository, and it has no parents, we only need to pass in
ever in this new repository, and it has no parents, we only need to pass in
the object name of the tree. However, 'git-commit-tree' also wants to get a
the object name of the tree. However, 'git commit-tree' also wants to get a
commit message on its standard input, and it will write out the resulting
commit message on its standard input, and it will write out the resulting
object name for the commit to its standard output.
object name for the commit to its standard output.
And this is where we create the `.git/refs/heads/master` file
And this is where we create the `.git/refs/heads/master` file
which is pointed at by `HEAD`. This file is supposed to contain
which is pointed at by `HEAD`. This file is supposed to contain
the reference to the top-of-tree of the master branch, and since
the reference to the top-of-tree of the master branch, and since
that's exactly what 'git-commit-tree' spits out, we can do this
that's exactly what 'git commit-tree' spits out, we can do this
all with a sequence of simple shell commands:
all with a sequence of simple shell commands:
------------------------------------------------
------------------------------------------------
@ -345,11 +345,11 @@ instead, and it would have done the above magic scripting for you.
Making a change
Making a change
---------------
---------------
Remember how we did the 'git-update-index' on file `hello` and then we
Remember how we did the 'git update-index' on file `hello` and then we
changed `hello` afterward, and could compare the new state of `hello` with the
changed `hello` afterward, and could compare the new state of `hello` with the
state we saved in the index file?
state we saved in the index file?
Further, remember how I said that 'git-write-tree' writes the contents
Further, remember how I said that 'git write-tree' writes the contents
of the *index* file to the tree, and thus what we just committed was in
of the *index* file to the tree, and thus what we just committed was in
fact the *original* contents of the file `hello`, not the new ones. We did
fact the *original* contents of the file `hello`, not the new ones. We did
that on purpose, to show the difference between the index state, and the
that on purpose, to show the difference between the index state, and the
@ -360,12 +360,12 @@ As before, if we do `git diff-files -p` in our git-tutorial project,
we'll still see the same difference we saw last time: the index file
we'll still see the same difference we saw last time: the index file
hasn't changed by the act of committing anything. However, now that we
hasn't changed by the act of committing anything. However, now that we
have committed something, we can also learn to use a new command:
have committed something, we can also learn to use a new command:
'git-diff-index'.
'git diff-index'.
Unlike 'git-diff-files', which showed the difference between the index
Unlike 'git diff-files', which showed the difference between the index
file and the working tree, 'git-diff-index' shows the differences
file and the working tree, 'git diff-index' shows the differences
between a committed *tree* and either the index file or the working
between a committed *tree* and either the index file or the working
tree. In other words, 'git-diff-index' wants a tree to be diffed
tree. In other words, 'git diff-index' wants a tree to be diffed
against, and before we did the commit, we couldn't do that, because we
against, and before we did the commit, we couldn't do that, because we
didn't have anything to diff against.
didn't have anything to diff against.
@ -375,7 +375,7 @@ But now we can do
$ git diff-index -p HEAD
$ git diff-index -p HEAD
----------------
----------------
(where `-p` has the same meaning as it did in 'git-diff-files'), and it
(where `-p` has the same meaning as it did in 'git diff-files'), and it
will show us the same difference, but for a totally different reason.
will show us the same difference, but for a totally different reason.
Now we're comparing the working tree not against the index file,
Now we're comparing the working tree not against the index file,
but against the tree we just wrote. It just so happens that those two
but against the tree we just wrote. It just so happens that those two
@ -390,7 +390,7 @@ $ git diff HEAD
which ends up doing the above for you.
which ends up doing the above for you.
In other words, 'git-diff-index' normally compares a tree against the
In other words, 'git diff-index' normally compares a tree against the
working tree, but when given the `\--cached` flag, it is told to
working tree, but when given the `\--cached` flag, it is told to
instead compare against just the index cache contents, and ignore the
instead compare against just the index cache contents, and ignore the
current working tree state entirely. Since we just wrote the index
current working tree state entirely. Since we just wrote the index
@ -399,7 +399,7 @@ an empty set of differences, and that's exactly what it does.
[NOTE]
[NOTE]
================
================
'git-diff-index' really always uses the index for its
'git diff-index' really always uses the index for its
comparisons, and saying that it compares a tree against the working
comparisons, and saying that it compares a tree against the working
tree is thus not strictly accurate. In particular, the list of
tree is thus not strictly accurate. In particular, the list of
files to compare (the "meta-data") *always* comes from the index file,
files to compare (the "meta-data") *always* comes from the index file,
@ -428,11 +428,11 @@ $ git update-index hello
(note how we didn't need the `\--add` flag this time, since git knew
(note how we didn't need the `\--add` flag this time, since git knew
about the file already).
about the file already).
Note what happens to the different 'git-diff-\*' versions here. After
Note what happens to the different 'git diff-\*' versions here. After
we've updated `hello` in the index, `git diff-files -p` now shows no
we've updated `hello` in the index, `git diff-files -p` now shows no
differences, but `git diff-index -p HEAD` still *does* show that the
differences, but `git diff-index -p HEAD` still *does* show that the
current state is different from the state we committed. In fact, now
current state is different from the state we committed. In fact, now
'git-diff-index' shows the same difference whether we use the `--cached`
'git diff-index' shows the same difference whether we use the `--cached`
flag or not, since now the index is coherent with the working tree.
flag or not, since now the index is coherent with the working tree.
Now, since we've updated `hello` in the index, we can commit the new
Now, since we've updated `hello` in the index, we can commit the new
@ -460,7 +460,7 @@ You've now made your first real git commit. And if you're interested in
looking at what `git commit` really does, feel free to investigate:
looking at what `git commit` really does, feel free to investigate:
it's a few very simple shell scripts to generate the helpful (?) commit
it's a few very simple shell scripts to generate the helpful (?) commit
message headers, and a few one-liners that actually do the
message headers, and a few one-liners that actually do the
commit itself ('git-commit').
commit itself ('git commit').
Inspecting Changes
Inspecting Changes
@ -468,9 +468,9 @@ Inspecting Changes
While creating changes is useful, it's even more useful if you can tell
While creating changes is useful, it's even more useful if you can tell
later what changed. The most useful command for this is another of the
later what changed. The most useful command for this is another of the
'diff' family, namely 'git-diff-tree'.
'diff' family, namely 'git diff-tree'.
'git-diff-tree' can be given two arbitrary trees, and it will tell you the
'git diff-tree' can be given two arbitrary trees, and it will tell you the
differences between them. Perhaps even more commonly, though, you can
differences between them. Perhaps even more commonly, though, you can
give it just a single commit object, and it will figure out the parent
give it just a single commit object, and it will figure out the parent
of that commit itself, and show the difference directly. Thus, to get
of that commit itself, and show the difference directly. Thus, to get
@ -518,15 +518,15 @@ various diff-\* commands compare things.
+-----------+
+-----------+
============
============
More interestingly, you can also give 'git-diff-tree' the `--pretty` flag,
More interestingly, you can also give 'git diff-tree' the `--pretty` flag,
which tells it to also show the commit message and author and date of the
which tells it to also show the commit message and author and date of the
commit, and you can tell it to show a whole series of diffs.
commit, and you can tell it to show a whole series of diffs.
Alternatively, you can tell it to be "silent", and not show the diffs at
Alternatively, you can tell it to be "silent", and not show the diffs at
all, but just show the actual commit message.
all, but just show the actual commit message.
In fact, together with the 'git-rev-list' program (which generates a
In fact, together with the 'git rev-list' program (which generates a
list of revisions), 'git-diff-tree' ends up being a veritable fount of
list of revisions), 'git diff-tree' ends up being a veritable fount of
changes. A trivial (but very useful) script called 'git-whatchanged' is
changes. A trivial (but very useful) script called 'git whatchanged' is
included with git which does exactly this, and shows a log of recent
included with git which does exactly this, and shows a log of recent
activities.
activities.
@ -553,14 +553,14 @@ When using the above two commands, the initial commit will be shown.
If this is a problem because it is huge, you can hide it by setting
If this is a problem because it is huge, you can hide it by setting
the log.showroot configuration variable to false. Having this, you
the log.showroot configuration variable to false. Having this, you
can still show it for each command just adding the `\--root` option,
can still show it for each command just adding the `\--root` option,
which is a flag for 'git-diff-tree' accepted by both commands.
which is a flag for 'git diff-tree' accepted by both commands.
With that, you should now be having some inkling of what git does, and
With that, you should now be having some inkling of what git does, and
can explore on your own.
can explore on your own.
[NOTE]
[NOTE]
Most likely, you are not directly using the core
Most likely, you are not directly using the core
git Plumbing commands, but using Porcelain such as 'git-add', `git-rm'
git Plumbing commands, but using Porcelain such as 'git add', `git-rm'
and `git-commit'.
and `git-commit'.
@ -595,7 +595,7 @@ pointer to the state you want to tag, but also a small tag name and
message, along with optionally a PGP signature that says that yes,
message, along with optionally a PGP signature that says that yes,
you really did
you really did
that tag. You create these annotated tags with either the `-a` or
that tag. You create these annotated tags with either the `-a` or
`-s` flag to 'git-tag':
`-s` flag to 'git tag':
----------------
----------------
$ git tag -s <tagname>
$ git tag -s <tagname>
@ -642,7 +642,7 @@ and it will be gone. There's no external repository, and there's no
history outside the project you created.
history outside the project you created.
- if you want to move or duplicate a git repository, you can do so. There
- if you want to move or duplicate a git repository, you can do so. There
is 'git-clone' command, but if all you want to do is just to
is 'git clone' command, but if all you want to do is just to
create a copy of your repository (with all the full history that
create a copy of your repository (with all the full history that
went along with it), you can do so with a regular
went along with it), you can do so with a regular
`cp -a git-tutorial new-git-tutorial`.
`cp -a git-tutorial new-git-tutorial`.
@ -666,7 +666,7 @@ When copying a remote repository, you'll want to at a minimum update the
index cache when you do this, and especially with other peoples'
index cache when you do this, and especially with other peoples'
repositories you often want to make sure that the index cache is in some
repositories you often want to make sure that the index cache is in some
known state (you don't know *what* they've done and not yet checked in),
known state (you don't know *what* they've done and not yet checked in),
so usually you'll precede the 'git-update-index' with a
so usually you'll precede the 'git update-index' with a
----------------
----------------
$ git read-tree --reset HEAD
$ git read-tree --reset HEAD
@ -674,7 +674,7 @@ $ git update-index --refresh
----------------
----------------
which will force a total index re-build from the tree pointed to by `HEAD`.
which will force a total index re-build from the tree pointed to by `HEAD`.
It resets the index contents to `HEAD`, and then the 'git-update-index'
It resets the index contents to `HEAD`, and then the 'git update-index'
makes sure to match up all index entries with the checked-out files.
makes sure to match up all index entries with the checked-out files.
If the original repository had uncommitted changes in its
If the original repository had uncommitted changes in its
working tree, `git update-index --refresh` notices them and
working tree, `git update-index --refresh` notices them and
@ -689,8 +689,8 @@ $ git reset
and in fact a lot of the common git command combinations can be scripted
and in fact a lot of the common git command combinations can be scripted
with the `git xyz` interfaces. You can learn things by just looking
with the `git xyz` interfaces. You can learn things by just looking
at what the various git scripts do. For example, `git reset` used to be
at what the various git scripts do. For example, `git reset` used to be
the above two lines implemented in 'git-reset', but some things like
the above two lines implemented in 'git reset', but some things like
'git-status' and 'git-commit' are slightly more complex scripts around
'git status' and 'git commit' are slightly more complex scripts around
the basic git commands.
the basic git commands.
Many (most?) public remote repositories will not contain any of
Many (most?) public remote repositories will not contain any of
@ -729,7 +729,7 @@ where the `-u` flag means that you want the checkout to keep the index
up-to-date (so that you don't have to refresh it afterward), and the
up-to-date (so that you don't have to refresh it afterward), and the
`-a` flag means "check out all files" (if you have a stale copy or an
`-a` flag means "check out all files" (if you have a stale copy or an
older version of a checked out tree you may also need to add the `-f`
older version of a checked out tree you may also need to add the `-f`
flag first, to tell 'git-checkout-index' to *force* overwriting of any old
flag first, to tell 'git checkout-index' to *force* overwriting of any old
files).
files).
Again, this can all be simplified with
Again, this can all be simplified with
@ -776,7 +776,7 @@ to it.
================================================
================================================
If you make the decision to start your new branch at some
If you make the decision to start your new branch at some
other point in the history than the current `HEAD`, you can do so by
other point in the history than the current `HEAD`, you can do so by
just telling 'git-checkout' what the base of the checkout would be.
just telling 'git checkout' what the base of the checkout would be.
In other words, if you have an earlier tag or branch, you'd just do
In other words, if you have an earlier tag or branch, you'd just do
------------
------------
@ -819,7 +819,7 @@ $ git branch <branchname> [startingpoint]
which will simply _create_ the branch, but will not do anything further.
which will simply _create_ the branch, but will not do anything further.
You can then later -- once you decide that you want to actually develop
You can then later -- once you decide that you want to actually develop
on that branch -- switch to that branch with a regular 'git-checkout'
on that branch -- switch to that branch with a regular 'git checkout'
with the branchname as the argument.
with the branchname as the argument.
@ -881,7 +881,7 @@ source.
Anyway, let's exit 'gitk' (`^Q` or the File menu), and decide that we want
Anyway, let's exit 'gitk' (`^Q` or the File menu), and decide that we want
to merge the work we did on the `mybranch` branch into the `master`
to merge the work we did on the `mybranch` branch into the `master`
branch (which is currently our `HEAD` too). To do that, there's a nice
branch (which is currently our `HEAD` too). To do that, there's a nice
script called 'git-merge', which wants to know which branches you want
script called 'git merge', which wants to know which branches you want
to resolve and what the merge is all about:
to resolve and what the merge is all about:
------------
------------
@ -925,7 +925,7 @@ $ git commit -i hello
which will very loudly warn you that you're now committing a merge
which will very loudly warn you that you're now committing a merge
(which is correct, so never mind), and you can write a small merge
(which is correct, so never mind), and you can write a small merge
message about your adventures in 'git-merge'-land.
message about your adventures in 'git merge'-land.
After you're done, start up `gitk \--all` to see graphically what the
After you're done, start up `gitk \--all` to see graphically what the
history looks like. Notice that `mybranch` still exists, and you can
history looks like. Notice that `mybranch` still exists, and you can
@ -967,21 +967,21 @@ branch head. Please see linkgit:git-rev-parse[1] if you want to
see more complex cases.
see more complex cases.
[NOTE]
[NOTE]
Without the '--more=1' option, 'git-show-branch' would not output the
Without the '--more=1' option, 'git show-branch' would not output the
'[master^]' commit, as '[mybranch]' commit is a common ancestor of
'[master^]' commit, as '[mybranch]' commit is a common ancestor of
both 'master' and 'mybranch' tips. Please see linkgit:git-show-branch[1]
both 'master' and 'mybranch' tips. Please see linkgit:git-show-branch[1]
for details.
for details.
[NOTE]
[NOTE]
If there were more commits on the 'master' branch after the merge, the
If there were more commits on the 'master' branch after the merge, the
merge commit itself would not be shown by 'git-show-branch' by
merge commit itself would not be shown by 'git show-branch' by
default. You would need to provide '--sparse' option to make the
default. You would need to provide '--sparse' option to make the
merge commit visible in this case.
merge commit visible in this case.
Now, let's pretend you are the one who did all the work in
Now, let's pretend you are the one who did all the work in
`mybranch`, and the fruit of your hard work has finally been merged
`mybranch`, and the fruit of your hard work has finally been merged
to the `master` branch. Let's go back to `mybranch`, and run
to the `master` branch. Let's go back to `mybranch`, and run
'git-merge' to get the "upstream changes" back to your branch.
'git merge' to get the "upstream changes" back to your branch.
------------
------------
$ git checkout mybranch
$ git checkout mybranch
@ -1023,12 +1023,12 @@ Merging external work
It's usually much more common that you merge with somebody else than
It's usually much more common that you merge with somebody else than
merging with your own branches, so it's worth pointing out that git
merging with your own branches, so it's worth pointing out that git
makes that very easy too, and in fact, it's not that different from
makes that very easy too, and in fact, it's not that different from
doing a 'git-merge'. In fact, a remote merge ends up being nothing
doing a 'git merge'. In fact, a remote merge ends up being nothing
more than "fetch the work from a remote repository into a temporary tag"
more than "fetch the work from a remote repository into a temporary tag"
followed by a 'git-merge'.
followed by a 'git merge'.
Fetching from a remote repository is done by, unsurprisingly,
Fetching from a remote repository is done by, unsurprisingly,
'git-fetch':
'git fetch':
----------------
----------------
$ git fetch <remote-repository>
$ git fetch <remote-repository>
@ -1095,7 +1095,7 @@ The 'commit walkers' are sometimes also called 'dumb
transports', because they do not require any git aware smart
transports', because they do not require any git aware smart
server like git Native transport does. Any stock HTTP server
server like git Native transport does. Any stock HTTP server
that does not even support directory index would suffice. But
that does not even support directory index would suffice. But
you must prepare your repository with 'git-update-server-info'
you must prepare your repository with 'git update-server-info'
to help dumb transport downloaders.
to help dumb transport downloaders.
Once you fetch from the remote repository, you `merge` that
Once you fetch from the remote repository, you `merge` that
@ -1115,7 +1115,7 @@ argument.
[NOTE]
[NOTE]
You could do without using any branches at all, by
You could do without using any branches at all, by
keeping as many local repositories as you would like to have
keeping as many local repositories as you would like to have
branches, and merging between them with 'git-pull', just like
branches, and merging between them with 'git pull', just like
you merge between branches. The advantage of this approach is
you merge between branches. The advantage of this approach is
that it lets you keep a set of files for each `branch` checked
that it lets you keep a set of files for each `branch` checked
out and you may find it easier to switch back and forth if you
out and you may find it easier to switch back and forth if you
@ -1132,7 +1132,7 @@ like this:
$ git config remote.linus.url http://www.kernel.org/pub/scm/git/git.git/
$ git config remote.linus.url http://www.kernel.org/pub/scm/git/git.git/
------------------------------------------------
------------------------------------------------
and use the "linus" keyword with 'git-pull' instead of the full URL.
and use the "linus" keyword with 'git pull' instead of the full URL.
Examples.
Examples.
@ -1168,7 +1168,7 @@ $ git show-branch --more=2 master mybranch
+* [master^] Some fun.
+* [master^] Some fun.
------------
------------
Remember, before running 'git-merge', our `master` head was at
Remember, before running 'git merge', our `master` head was at
"Some fun." commit, while our `mybranch` head was at "Some
"Some fun." commit, while our `mybranch` head was at "Some
work." commit.
work." commit.
@ -1195,7 +1195,7 @@ Now we are ready to experiment with the merge by hand.
`git merge` command, when merging two branches, uses 3-way merge
`git merge` command, when merging two branches, uses 3-way merge
algorithm. First, it finds the common ancestor between them.
algorithm. First, it finds the common ancestor between them.
The command it uses is 'git-merge-base':
The command it uses is 'git merge-base':
------------
------------
$ mb=$(git merge-base HEAD mybranch)
$ mb=$(git merge-base HEAD mybranch)
@ -1219,7 +1219,7 @@ this:
$ git read-tree -m -u $mb HEAD mybranch
$ git read-tree -m -u $mb HEAD mybranch
------------
------------
This is the same 'git-read-tree' command we have already seen,
This is the same 'git read-tree' command we have already seen,
but it takes three trees, unlike previous examples. This reads
but it takes three trees, unlike previous examples. This reads
the contents of each tree into different 'stage' in the index
the contents of each tree into different 'stage' in the index
file (the first tree goes to stage 1, the second to stage 2,
file (the first tree goes to stage 1, the second to stage 2,
@ -1260,8 +1260,8 @@ $ git ls-files --unmerged
The next step of merging is to merge these three versions of the
The next step of merging is to merge these three versions of the
file, using 3-way merge. This is done by giving
file, using 3-way merge. This is done by giving
'git-merge-one-file' command as one of the arguments to
'git merge-one-file' command as one of the arguments to
'git-merge-index' command:
'git merge-index' command:
------------
------------
$ git merge-index git-merge-one-file hello
$ git merge-index git-merge-one-file hello
@ -1270,7 +1270,7 @@ ERROR: Merge conflict in hello
fatal: merge program failed
fatal: merge program failed
------------
------------
'git-merge-one-file' script is called with parameters to
'git merge-one-file' script is called with parameters to
describe those three versions, and is responsible to leave the
describe those three versions, and is responsible to leave the
merge results in the working tree.
merge results in the working tree.
It is a fairly straightforward shell script, and
It is a fairly straightforward shell script, and
@ -1289,9 +1289,9 @@ $ git ls-files --stage
------------
------------
This is the state of the index file and the working file after
This is the state of the index file and the working file after
'git-merge' returns control back to you, leaving the conflicting
'git merge' returns control back to you, leaving the conflicting
merge for you to resolve. Notice that the path `hello` is still
merge for you to resolve. Notice that the path `hello` is still
unmerged, and what you see with 'git-diff' at this point is
unmerged, and what you see with 'git diff' at this point is
differences since stage 2 (i.e. your version).
differences since stage 2 (i.e. your version).
@ -1328,8 +1328,8 @@ into it later. Obviously, this repository creation needs to be
done only once.
done only once.
[NOTE]
[NOTE]
'git-push' uses a pair of commands,
'git push' uses a pair of commands,
'git-send-pack' on your local machine, and 'git-receive-pack'
'git send-pack' on your local machine, and 'git-receive-pack'
on the remote machine. The communication between the two over
on the remote machine. The communication between the two over
the network internally uses an SSH connection.
the network internally uses an SSH connection.
@ -1344,7 +1344,7 @@ $ mkdir my-git.git
------------
------------
Then, make that directory into a git repository by running
Then, make that directory into a git repository by running
'git-init', but this time, since its name is not the usual
'git init', but this time, since its name is not the usual
`.git`, we do things slightly differently:
`.git`, we do things slightly differently:
------------
------------
@ -1407,7 +1407,7 @@ $ git repack
will do it for you. If you followed the tutorial examples, you
will do it for you. If you followed the tutorial examples, you
would have accumulated about 17 objects in `.git/objects/??/`
would have accumulated about 17 objects in `.git/objects/??/`
directories by now. 'git-repack' tells you how many objects it
directories by now. 'git repack' tells you how many objects it
packed, and stores the packed file in `.git/objects/pack`
packed, and stores the packed file in `.git/objects/pack`
directory.
directory.
@ -1420,7 +1420,7 @@ them together. The former holds all the data from the objects
in the pack, and the latter holds the index for random
in the pack, and the latter holds the index for random
access.
access.
If you are paranoid, running 'git-verify-pack' command would
If you are paranoid, running 'git verify-pack' command would
detect if you have a corrupt pack, but do not worry too much.
detect if you have a corrupt pack, but do not worry too much.
Our programs are always perfect ;-).
Our programs are always perfect ;-).
@ -1487,17 +1487,17 @@ If other people are pulling from your repository over dumb
transport protocols (HTTP), you need to keep this repository
transport protocols (HTTP), you need to keep this repository
'dumb transport friendly'. After `git init`,
'dumb transport friendly'. After `git init`,
`$GIT_DIR/hooks/post-update.sample` copied from the standard templates
`$GIT_DIR/hooks/post-update.sample` copied from the standard templates
would contain a call to 'git-update-server-info'
would contain a call to 'git update-server-info'
but you need to manually enable the hook with
but you need to manually enable the hook with
`mv post-update.sample post-update`. This makes sure
`mv post-update.sample post-update`. This makes sure
'git-update-server-info' keeps the necessary files up-to-date.
'git update-server-info' keeps the necessary files up-to-date.
3. Push into the public repository from your primary
3. Push into the public repository from your primary
repository.
repository.
4. 'git-repack' the public repository. This establishes a big
4. 'git repack' the public repository. This establishes a big
pack that contains the initial set of objects as the
pack that contains the initial set of objects as the
baseline, and possibly 'git-prune' if the transport
baseline, and possibly 'git prune' if the transport
used for pulling from your repository supports packed
used for pulling from your repository supports packed
repositories.
repositories.
@ -1511,14 +1511,14 @@ You can repack this private repository whenever you feel like.
6. Push your changes to the public repository, and announce it
6. Push your changes to the public repository, and announce it
to the public.
to the public.
7. Every once in a while, 'git-repack' the public repository.
7. Every once in a while, 'git repack' the public repository.
Go back to step 5. and continue working.
Go back to step 5. and continue working.
A recommended work cycle for a "subsystem maintainer" who works
A recommended work cycle for a "subsystem maintainer" who works
on that project and has an own "public repository" goes like this:
on that project and has an own "public repository" goes like this:
1. Prepare your work repository, by 'git-clone' the public
1. Prepare your work repository, by 'git clone' the public
repository of the "project lead". The URL used for the
repository of the "project lead". The URL used for the
initial cloning is stored in the remote.origin.url
initial cloning is stored in the remote.origin.url
configuration variable.
configuration variable.
@ -1533,7 +1533,7 @@ on that project and has an own "public repository" goes like this:
point at the repository you are borrowing from.
point at the repository you are borrowing from.
4. Push into the public repository from your primary
4. Push into the public repository from your primary
repository. Run 'git-repack', and possibly 'git-prune' if the
repository. Run 'git repack', and possibly 'git prune' if the
transport used for pulling from your repository supports
transport used for pulling from your repository supports
packed repositories.
packed repositories.
@ -1550,7 +1550,7 @@ like.
"project lead" and possibly your "sub-subsystem
"project lead" and possibly your "sub-subsystem
maintainers" to pull from it.
maintainers" to pull from it.
7. Every once in a while, 'git-repack' the public repository.
7. Every once in a while, 'git repack' the public repository.
Go back to step 5. and continue working.
Go back to step 5. and continue working.
@ -1558,7 +1558,7 @@ A recommended work cycle for an "individual developer" who does
not have a "public" repository is somewhat different. It goes
not have a "public" repository is somewhat different. It goes
like this:
like this:
1. Prepare your work repository, by 'git-clone' the public
1. Prepare your work repository, by 'git clone' the public
repository of the "project lead" (or a "subsystem
repository of the "project lead" (or a "subsystem
maintainer", if you work on a subsystem). The URL used for
maintainer", if you work on a subsystem). The URL used for
the initial cloning is stored in the remote.origin.url
the initial cloning is stored in the remote.origin.url
@ -1656,8 +1656,8 @@ $ git reset --hard master~2
------------
------------
You can make sure `git show-branch` matches the state before
You can make sure `git show-branch` matches the state before
those two 'git-merge' you just did. Then, instead of running
those two 'git merge' you just did. Then, instead of running
two 'git-merge' commands in a row, you would merge these two
two 'git merge' commands in a row, you would merge these two
branch heads (this is known as 'making an Octopus'):
branch heads (this is known as 'making an Octopus'):
------------
------------