From 39381a7c839f85e6b5380251ecffcd5b1a214945 Mon Sep 17 00:00:00 2001
From: Junio C Hamano
git repositories are normally totally self-sufficient and relocatable +
git repositories are normally totally self-sufficient and relocatable. Unlike CVS, for example, there is no separate notion of "repository" and "working tree". A git repository normally is the working tree, with the local git information hidden in the .git @@ -1345,7 +1345,7 @@ argument.
keeping as many local repositories as you would like to have branches, and merging between them with git pull, just like you merge between branches. The advantage of this approach is -that it lets you keep 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 juggle multiple lines of development simultaneously. Of course, you will pay the price of more disk usage to hold @@ -1525,7 +1525,7 @@ differences since stage 2 (i.e. your version).So we can use somebody else's work from a remote repository; but +
So, we can use somebody else's work from a remote repository, but how can you prepare a repository to let other people pull from it?
Your do your real work in your working tree that has your @@ -1969,7 +1969,7 @@ to follow, not easier.
Table of Contents
This manual is designed to be readable by someone with basic unix +
Table of Contents
This manual is designed to be readable by someone with basic unix commandline skills, but no previous knowledge of git.
Chapter 1 gives a brief overview of git commands, without any explanation; you may prefer to skip to chapter 2 on a first reading.
Chapters 2 and 3 explain how to fetch and study a project using git—the tools you'd need to build and test a particular version of a @@ -154,7 +154,7 @@ branch name, but this longer name can also be useful. Most importantly, it is a globally unique name for this commit: so if you tell somebody else the object name (for example in email), then you are guaranteed that name will refer to the same commit in their repository -that you it does in yours (assuming their repository has that commit at +that it does in yours (assuming their repository has that commit at all).
Every commit (except the very first commit in a project) also has a parent commit which shows what happened before this commit. Following the chain of parents will eventually take you back to the @@ -280,7 +280,7 @@ text editor. (See the "CONFIGURATION FILE" section of collection of files. It does this by storing compressed snapshots of the contents of a file heirarchy, together with "commits" which show the relationships between these snapshots.
Git provides extremely flexible and fast tools for exploring the -history of a project.
We start with one specialized tool which is useful for finding the +history of a project.
We start with one specialized tool that is useful for finding the commit that introduced a bug into a project.
Suppose version 2.6.18 of your project worked, but the version at
"master" crashes. Sometimes the best way to find the cause of such a
regression is to perform a brute-force search through the project's
@@ -596,7 +596,7 @@ the lost commits; run git-fsck and watch for output that mentions
dangling commit 7281251ddd2a61e38657c827739c57015671a6b3
dangling commit 2706a059f258c6b245f298dc4ff2ccd30ec21a63
dangling commit 13472b7c4b80851a1bc551779171dcb03655e9b5
-...
and watch for output that mentions "dangling commits". You can examine +...
You can examine one of those dangling commits with, for example,
$ gitk 7281251ddd --not --all
which does what it sounds like: it says that you want to see the commit history that is described by the dangling commit(s), but not the history that is described by all your existing branches and tags. Thus @@ -604,7 +604,7 @@ you get exactly the history reachable from that commit that is lost. (And notice that it might not be just one commit: we only report the "tip of the line" as being dangling, but there might be a whole deep and complex commit history that was gotten dropped.)
If you decide you want the history back, you can always create a new -reference pointing to it, for example, a new branch:
$ git branch recovered-branch 7281251ddd
Table of Contents
Table of Contents
After you clone a repository and make a few changes of your own, you may wish to check the original repository for updates and merge them into your own work.
We have already seen how to keep remote tracking branches up to date with git-fetch(1), and how to merge two branches. So you can merge in changes from the @@ -621,13 +621,13 @@ repository that you pulled from.
(But note that no such commit will be cre updated to point to the latest commit from the upstream branch).
The git-pull command can also be given "." as the "remote" repository, in which case it just merges in a branch from the current repository; so the commands
$ git pull . branch
-$ git merge branch
are roughly equivalent. The former is actually very commonly used.
If you just have a few changes, the simplest way to submit them may +$ git merge branch
are roughly equivalent. The former is actually very commonly used.
If you just have a few changes, the simplest way to submit them may just be to send them as patches in email:
First, use git-format-patch(1); for example:
$ git format-patch origin
will produce a numbered series of files in the current directory, one for each patch in the current branch but not in origin/HEAD.
You can then import these into your mail client and send them by hand. However, if you have a lot to send at once, you may prefer to use the git-send-email(1) script to automate the process. Consult the mailing list for your project first to determine how they -prefer such patches be handled.
Git also provides a tool called git-am(1) (am stands for +prefer such patches be handled.
Git also provides a tool called git-am(1) (am stands for "apply mailbox"), for importing such an emailed series of patches. Just save all of the patch-containing messages, in order, into a single mailbox file, say "patches.mbox", then run
$ git am -3 patches.mbox
Git will apply each patch in order; if any conflicts are found, it @@ -699,16 +699,16 @@ save typing; so, for example, after
$
url = ssh://yourserver.com/~you/proj.git
EOF
you should be able to perform the above push with just
$ git push public-repo master
See the explanations of the remote.<name>.url, branch.<name>.remote, and remote.<name>.push options in git-config(1) for -details.
Another way to collaborate is by using a model similar to that +details.
Another way to collaborate is by using a model similar to that commonly used in CVS, where several developers with special rights all push to and pull from a single shared repository. See git for CVS users for instructions on how to -set this up.
The gitweb cgi script provides users an easy way to browse your +set this up.
The gitweb cgi script provides users an easy way to browse your project's files and history without having to install git; see the file -gitweb/README in the git source tree for instructions on setting it up.
Table of Contents
Normally commits are only added to a project, never taken away or +gitweb/README in the git source tree for instructions on setting it up.
Table of Contents
Normally commits are only added to a project, never taken away or replaced. Git is designed with this assumption, and violating it will cause git's merge machinery (for example) to do the wrong thing.
However, there is a situation in which it can be useful to violate this -assumption.
Suppose you are a contributor to a large project, and you want to add a +assumption.
Suppose you are a contributor to a large project, and you want to add a complicated feature, and to present it to the other developers in a way that makes it easy for them to read your changes, verify that they are correct, and understand why you made each change.
If you present all of your changes as a single patch (or commit), they @@ -727,7 +727,7 @@ The complete series produces the same end result as your own (probably much messier!) development process did.
We will introduce some tools that can help you do this, explain how to use them, and then explain some of the problems that can arise because -you are rewriting history.
Suppose you have a series of commits in a branch "mywork", which +you are rewriting history.
Suppose you have a series of commits in a branch "mywork", which originally branched off from "origin".
Suppose you create a branch "mywork" on a remote-tracking branch "origin", and created some commits on top of it:
$ git checkout -b mywork origin
$ vi file.txt
@@ -751,7 +751,7 @@ patches to the new mywork. The result will look like:
$ git rebase --continue
and git will continue applying the rest of the patches.
At any point you may use the —abort option to abort this process and -return mywork to the state it had before you started the rebase:
$ git rebase --abort
Given one existing commit, the git-cherry-pick(1) command +return mywork to the state it had before you started the rebase:
$ git rebase --abort
Given one existing commit, the git-cherry-pick(1) command allows you to apply the change introduced by that commit and create a new commit that records it. So, for example, if "mywork" points to a series of patches on top of "origin", you might do something like:
$ git checkout -b mywork-new origin
@@ -761,9 +761,9 @@ cherry-pick, and possibly modifying them as you go using commit
—amend.
Another technique is to use git-format-patch to create a series of patches, then reset the state to before the patches:
$ git format-patch origin
$ git reset --hard origin
Then modify, reorder, or eliminate patches as preferred before applying -them again with git-am(1).
There are numerous other tools, such as stgit, which exist for the +them again with git-am(1).
There are numerous other tools, such as stgit, which exist for the purpose of maintaining a patch series. These are out of the scope of -this manual.
The primary problem with rewriting the history of a branch has to do +this manual.
The primary problem with rewriting the history of a branch has to do with merging. Suppose somebody fetches your branch and merges it into their branch, with a result something like this:
o--o--O--o--o--o <-- origin \ t--t--t--m <-- their branch:
Then suppose you modify the last three commits:
o--o--o <-- new head of origin @@ -782,7 +782,7 @@ new. The results are likely to be unexpected.You may still choose to pub and it may be useful for others to be able to fetch those branches in order to examine or test them, but they should not attempt to pull such branches into their own work.
For true distributed development that supports proper merging, -published branches should never be rewritten.
Table of Contents
Instead of using git-remote(1), you can also choose just +published branches should never be rewritten.
Table of Contents
Instead of using git-remote(1), you can also choose just to update one branch at a time, and to store it locally under an arbitrary name:
$ git fetch origin todo:my-todo-work
The first argument, "origin", just tells git to fetch from the repository you originally cloned from. The second argument tells git @@ -804,10 +804,10 @@ resulting in a situation like:
o--o--o--o--a--b &l described in the following section. However, note that in the situation above this may mean losing the commits labeled "a" and "b", unless you've already created a reference of your own pointing to -them.
If git fetch fails because the new head of a branch is not a +them.
If git fetch fails because the new head of a branch is not a descendant of the old head, you may force the update with:
$ git fetch git://example.com/proj.git +master:refs/remotes/example/master
Note the addition of the "+" sign. Be aware that commits which the old version of example/master pointed at may be lost, as we saw in -the previous section.
We saw above that "origin" is just a shortcut to refer to the +the previous section.
We saw above that "origin" is just a shortcut to refer to the repository which you originally cloned from. This information is stored in git configuration variables, which you can see using git-config(1):
$ git config -l
@@ -827,8 +827,8 @@ $
throwing away commits on mybranch.
Also note that all of the above configuration can be performed by directly editing the file .git/config instead of using git-config(1).
See git-config(1) for more details on the configuration -options mentioned above.
Table of Contents
There are two object abstractions: the "object database", and the -"current directory cache" aka "index".
Table of Contents
There are two object abstractions: the "object database", and the +"current directory cache" aka "index".
The object database is literally just a content-addressable collection of objects. All objects are named by their content, which is approximated by the SHA1 hash of the object itself. Objects may refer to other objects (by referencing their SHA1 hash), and so you can @@ -870,7 +870,7 @@ size> + <byte\0> + <binary object data>.
The structured obj
connectivity to other objects verified. This is generally done with
the git-fsck
program, which generates a full dependency graph
of all objects, and verifies their internal consistency (in addition
-to just verifying their superficial consistency through the hash).
The object types in some more detail:
A "blob" object is nothing but a binary blob of data, and doesn't +to just verifying their superficial consistency through the hash).
The object types in some more detail:
A "blob" object is nothing but a binary blob of data, and doesn't refer to anything else. There is no signature or any other verification of the data, so while the object is consistent (it is indexed by its sha1 hash, so the data itself is certainly correct), it @@ -882,7 +882,7 @@ repository) have the same contents, they will share the same blob object. The object is totally independent of its location in the directory tree, and renaming a file does not change the object that file is associated with in any way.
A blob is typically created when git-update-index(1) -is run, and its data can be accessed by git-cat-file(1).
The next hierarchical object type is the "tree" object. A tree object +is run, and its data can be accessed by git-cat-file(1).
The next hierarchical object type is the "tree" object. A tree object is a list of mode/name/blob data, sorted by name. Alternatively, the mode data may specify a directory mode, in which case instead of naming a blob, that name is associated with another TREE object.
Like the "blob" object, a tree object is uniquely determined by the @@ -906,7 +906,7 @@ involved), you can see trivial renames or permission changes by noticing that the blob stayed the same. However, renames with data changes need a smarter "diff" implementation.
A tree is created with git-write-tree(1) and its data can be accessed by git-ls-tree(1). -Two trees can be compared with git-diff-tree(1).
The "commit" object is an object that introduces the notion of +Two trees can be compared with git-diff-tree(1).
The "commit" object is an object that introduces the notion of history into the picture. In contrast to the other objects, it doesn't just describe the physical state of a tree, it describes how we got there, and why.
A "commit" is defined by the tree-object that it results in, the @@ -921,7 +921,7 @@ rename information or file mode change information. All of that is implicit in the trees involved (the result tree, and the result trees of the parents), and describing that makes no sense in this idiotic file manager.
A commit is created with git-commit-tree(1) and -its data can be accessed by git-cat-file(1).
An aside on the notion of "trust". Trust is really outside the scope +its data can be accessed by git-cat-file(1).
An aside on the notion of "trust". Trust is really outside the scope of "git", but it's worth noting a few things. First off, since everything is hashed with SHA1, you can trust that an object is intact and has not been messed with by external sources. So the name @@ -937,7 +937,7 @@ that you trust that commit, and the immutability of the history of commits tells others that they can trust the whole history.
In other words, you can easily validate a whole archive by just sending out a single email that tells the people the name (SHA1 hash) of the top commit, and digitally sign that email using something -like GPG/PGP.
To assist in this, git also provides the tag object…
Git provides the "tag" object to simplify creating, managing and +like GPG/PGP.
To assist in this, git also provides the tag object…
Git provides the "tag" object to simplify creating, managing and exchanging symbolic and signed tokens. The "tag" object at its simplest simply symbolically identifies another object by containing the sha1, type and symbolic name.
However it can optionally contain additional signature information @@ -947,7 +947,7 @@ integrity; the trust framework (and signature provision and verification) has to come from outside.
A tag is created with git-mktag(1), its data can be accessed by git-cat-file(1), and the signature can be verified by -git-verify-tag(1).
The index is a simple binary file, which contains an efficient +git-verify-tag(1).
The index is a simple binary file, which contains an efficient representation of a virtual directory content at some random time. It does so by a simple array that associates a set of names, dates, permissions and content (aka "blob") objects together. The cache is @@ -980,11 +980,11 @@ involves a controlled modification of the index file. In particular, the index file can have the representation of an intermediate tree that has not yet been instantiated. So the index can be thought of as a write-back cache, which can contain dirty information that has not yet -been written back to the backing store.
Generally, all "git" operations work on the index file. Some operations +been written back to the backing store.
Generally, all "git" operations work on the index file. Some operations work purely on the index file (showing the current state of the index), but most operations move data to and from the index file. Either from the database or from the working directory. Thus there are four -main combinations:
You update the index with information from the working directory with +main combinations:
You update the index with information from the working directory with the git-update-index(1) command. You generally update the index information by just specifying the filename you want to update, like so:
$ git-update-index filename
but to avoid common mistakes with filename globbing etc, the command @@ -1000,11 +1000,11 @@ does not exist any more, it will update the index accordingly.
As a specia will refresh the "stat" information of each index to match the current stat information. It will not update the object status itself, and it will only update the fields that are used to quickly test whether -an object still matches its old backing store object.
You write your current index file to a "tree" object with the program
$ git-write-tree
that doesn't come with any options - it will just write out the +an object still matches its old backing store object.
You write your current index file to a "tree" object with the program
$ git-write-tree
that doesn't come with any options - it will just write out the current index into the set of tree objects that describe that state, and it will return the name of the resulting top-level tree. You can use that tree to re-generate the index at any time by going in the -other direction:
You read a "tree" file from the object database, and use that to +other direction:
You read a "tree" file from the object database, and use that to populate (and overwrite - don't do this if your index contains any unsaved state that you might want to restore later!) your current index. Normal operation is just
$ git-read-tree <sha1 of tree>
and your index file will now be equivalent to the tree that you saved @@ -1020,7 +1020,7 @@ with
$ if you have an old version of the tree already checked out, you will need to use the "-f" flag (before the "-a" flag or the filename) to force the checkout.
Finally, there are a few odds and ends which are not purely moving -from one representation to the other:
To commit a tree you have instantiated with "git-write-tree", you'd +from one representation to the other:
To commit a tree you have instantiated with "git-write-tree", you'd create a "commit" object that refers to that tree and the history behind it - most notably the "parent" commits that preceded it in history.
Normally a "commit" has one parent: the previous state of the tree @@ -1069,7 +1069,7 @@ various pieces fit together.
| Working |
| Directory |
+-----------+
-
You can examine the data represented in the object database and the index with various helper tools. For every object, you can use git-cat-file(1) to examine details about the object:
$ git-cat-file -t <objectname>
shows the type of the object, and once you have the type (which is @@ -1079,7 +1079,7 @@ there is a special helper for showing that content, called readable form.
It's especially instructive to look at "commit" objects, since those
tend to be small and fairly self-explanatory. In particular, if you
follow the convention of having the top commit name in .git/HEAD
,
-you can do
$ git-cat-file commit HEAD
to see what the top commit was.
Git helps you do a three-way merge, which you can expand to n-way by +you can do
$ git-cat-file commit HEAD
to see what the top commit was.
Git helps you do a three-way merge, which you can expand to n-way by repeating the merge procedure arbitrary times until you finally "commit" the state. The normal situation is that you'd only do one three-way merge (two parents), and commit it, but if you like to, you @@ -1098,7 +1098,7 @@ make sure that you've committed those - in fact you would normally always do a merge against your last commit (which should thus match what you have in your current index anyway).
To do the merge, do
$ git-read-tree -m -u <origtree> <yourtree> <targettree>
which will do all trivial merge operations for you directly in the
index file, and you can just write the result out with
-git-write-tree
.
Sadly, many merges aren't trivial. If there are files that have
+git-write-tree
.
Sadly, many merges aren't trivial. If there are files that have been added.moved or removed, or if both branches have modified the same file, you will be left with an index tree that contains "merge entries" in it. Such an index tree can NOT be written out to a tree @@ -1133,7 +1133,7 @@ that path tells git to mark the path resolved.
The above is the descriptio
to help you understand what conceptually happens under the hood.
In practice, nobody, not even git itself, uses three git-cat-file
for this. There is git-merge-index
program that extracts the
-stages to temporary files and calls a "merge" script on it:
$ git-merge-index git-merge-one-file hello.c
and that is what higher level git resolve
is implemented with.
We've seen how git stores each object in a file named after the +stages to temporary files and calls a "merge" script on it:
$ git-merge-index git-merge-one-file hello.c
and that is what higher level git resolve
is implemented with.
We've seen how git stores each object in a file named after the object's SHA1 hash.
Unfortunately this system becomes inefficient once a project has a lot of objects. Try this on an old project:
$ git count-objects
6930 objects, 47620 kilobytes
The first number is the number of objects which are kept in @@ -1197,7 +1197,7 @@ on what it found, git-fsck itself is never "dangerous" to run. Running it while somebody is actually changing the repository can cause confusing and scary messages, but it won't actually do anything bad. In contrast, running "git prune" while somebody is actively changing the -repository is a BAD idea).
This is a work in progress.
The basic requirements: - It must be readable in order, from beginning to end, by someone intelligent with a basic grasp of the unix commandline, but without any special knowledge of git. If @@ -1631,7 +1631,7 @@ working tree no more knowledge than necessary: for example, "importing patches into a project" rather than "the git-am command"
Think about how to create a clear chapter dependency graph that will allow people to get to important topics without necessarily reading -everything in between.
Scan Documentation/ for other stuff left out; in particular: +everything in between.
Say something about .gitignore.
Scan Documentation/ for other stuff left out; in particular: howto's some of technical/? hooks diff --git a/user-manual.txt b/user-manual.txt index b6916d11b..6576625fa 100644 --- a/user-manual.txt +++ b/user-manual.txt @@ -398,7 +398,7 @@ branch name, but this longer name can also be useful. Most importantly, it is a globally unique name for this commit: so if you tell somebody else the object name (for example in email), then you are guaranteed that name will refer to the same commit in their repository -that you it does in yours (assuming their repository has that commit at +that it does in yours (assuming their repository has that commit at all). Understanding history: commits, parents, and reachability @@ -617,7 +617,7 @@ the relationships between these snapshots. Git provides extremely flexible and fast tools for exploring the history of a project. -We start with one specialized tool which is useful for finding the +We start with one specialized tool that is useful for finding the commit that introduced a bug into a project. How to use bisect to find a regression @@ -1492,7 +1492,7 @@ dangling commit 13472b7c4b80851a1bc551779171dcb03655e9b5 ... ------------------------------------------------- -and watch for output that mentions "dangling commits". You can examine +You can examine one of those dangling commits with, for example, ------------------------------------------------ @@ -2923,6 +2923,8 @@ Think about how to create a clear chapter dependency graph that will allow people to get to important topics without necessarily reading everything in between. +Say something about .gitignore. + Scan Documentation/ for other stuff left out; in particular: howto's some of technical/? -- 2.26.2
diff --git a/core-tutorial.txt b/core-tutorial.txt index 86a9c7521..1cd834b0f 100644 --- a/core-tutorial.txt +++ b/core-tutorial.txt @@ -624,7 +624,7 @@ name for the state at that point. Copying repositories -------------------- -git repositories are normally totally self-sufficient and relocatable +git repositories are normally totally self-sufficient and relocatable. Unlike CVS, for example, there is no separate notion of "repository" and "working tree". A git repository normally *is* the working tree, with the local git information hidden in the `.git` @@ -1118,7 +1118,7 @@ You could do without using any branches at all, by keeping as many local repositories as you would like to have branches, and merging between them with `git pull`, just like you merge between branches. The advantage of this approach is -that it lets you keep 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 juggle multiple lines of development simultaneously. Of course, you will pay the price of more disk usage to hold @@ -1300,7 +1300,7 @@ differences since stage 2 (i.e. your version). Publishing your work -------------------- -So we can use somebody else's work from a remote repository; but +So, we can use somebody else's work from a remote repository, but how can *you* prepare a repository to let other people pull from it? diff --git a/git-checkout.html b/git-checkout.html index 7b7053008..6557ba4e9 100644 --- a/git-checkout.html +++ b/git-checkout.html @@ -273,7 +273,7 @@ git-checkout(1) Manual Page
+ Quiet, supress feedback messages. +
+In the third form, gives some information about the remote <name>.
+In the fourth form, deletes all stale tracking branches under <name>. +These stale branches have already been removed from the remote repository +referenced by <name>, but are still locally available in "remotes/<name>".
The remote configuration is achieved using the remote.origin.url and remote.origin.fetch configuration variables. (See git-config(1)).
@@ -332,7 +336,7 @@ $ git checkout -b nfs linux-nfs/master
diff --git a/git-remote.txt b/git-remote.txt
index 358c1acfc..817651eaa 100644
--- a/git-remote.txt
+++ b/git-remote.txt
@@ -12,6 +12,7 @@ SYNOPSIS
'git-remote'
'git-remote' add
+You can use the @ construct with an empty ref part to get at a
+ reflog of the current branch. For example, if you are on the
+ branch blabla, then @{1} means the same as blabla@{1}.
+
A suffix ^ to a revision parameter means the first parent of
that commit object. ^<n> means the <n>th parent (i.e.
rev^
@@ -692,7 +699,7 @@ Junio C Hamano <junkio@cox.net>
diff --git a/user-manual.html b/user-manual.html index 573def8c6..9a44a3d15 100644 --- a/user-manual.html +++ b/user-manual.html @@ -1,4 +1,4 @@ -