@@ -57,7 +57,7 @@ Managing branches
57
57
-----------------
58
58
59
59
-----------------------------------------------
60
- $ git branch # list all branches in this repo
60
+ $ git branch # list all local branches in this repo
61
61
$ git checkout test # switch working directory to branch "test"
62
62
$ git branch new # create branch "new" starting at current HEAD
63
63
$ git branch -d new # delete branch "new"
@@ -496,8 +496,8 @@ git branch <branch> <start-point>::
496
496
including using a branch name or a tag name
497
497
git branch -d <branch>::
498
498
delete the branch <branch>; if the branch you are deleting
499
- points to a commit which is not reachable from this branch,
500
- this command will fail with a warning.
499
+ points to a commit which is not reachable from the current
500
+ branch, this command will fail with a warning.
501
501
git branch -D <branch>::
502
502
even if the branch points to a commit not reachable
503
503
from the current branch, you may know that that commit
@@ -602,13 +602,9 @@ shorthand:
602
602
The full name is occasionally useful if, for example, there ever
603
603
exists a tag and a branch with the same name.
604
604
605
- As another useful shortcut, if the repository "origin" posesses only
606
- a single branch, you can refer to that branch as just "origin".
607
-
608
- More generally, if you have defined a remote repository named
609
- "example", you can refer to the branch in that repository as
610
- "example". And for a repository with multiple branches, this will
611
- refer to the branch designated as the "HEAD" branch.
605
+ As another useful shortcut, the "HEAD" of a repository can be referred
606
+ to just using the name of that repository. So, for example, "origin"
607
+ is usually a shortcut for the HEAD branch in the repository "origin".
612
608
613
609
For the complete list of paths which git checks for references, and
614
610
the order it uses to decide which to choose when there are multiple
@@ -832,10 +828,10 @@ $ git tag stable-1 1b2e1d63ff
832
828
833
829
You can use stable-1 to refer to the commit 1b2e1d63ff.
834
830
835
- This creates a "lightweight" tag. If the tag is a tag you wish to
836
- share with others , and possibly sign cryptographically, then you
837
- should create a tag object instead; see the gitlink:git-tag[1] man
838
- page for details.
831
+ This creates a "lightweight" tag. If you would also like to include a
832
+ comment with the tag , and possibly sign it cryptographically, then you
833
+ should create a tag object instead; see the gitlink:git-tag[1] man page
834
+ for details.
839
835
840
836
[[browsing-revisions]]
841
837
Browsing revisions
@@ -1176,6 +1172,8 @@ $ git diff --cached # difference between HEAD and the index; what
1176
1172
$ git diff # difference between the index file and your
1177
1173
# working directory; changes that would not
1178
1174
# be included if you ran "commit" now.
1175
+ $ git diff HEAD # difference between HEAD and working tree; what
1176
+ # would be committed if you ran "commit -a" now.
1179
1177
$ git status # a brief per-file summary of the above.
1180
1178
-------------------------------------------------
1181
1179
@@ -1223,8 +1221,6 @@ If you examine the resulting commit using gitk, you will see that it
1223
1221
has two parents, one pointing to the top of the current branch, and
1224
1222
one to the top of the other branch.
1225
1223
1226
- In more detail:
1227
-
1228
1224
[[resolving-a-merge]]
1229
1225
Resolving a merge
1230
1226
-----------------
@@ -1361,6 +1357,9 @@ $ gitk --merge
1361
1357
These will display all commits which exist only on HEAD or on
1362
1358
MERGE_HEAD, and which touch an unmerged file.
1363
1359
1360
+ You may also use gitlink:git-mergetool, which lets you merge the
1361
+ unmerged files using external tools such as emacs or kdiff3.
1362
+
1364
1363
Each time you resolve the conflicts in a file and update the index:
1365
1364
1366
1365
-------------------------------------------------
@@ -1705,9 +1704,16 @@ so often you can accomplish the above with just
1705
1704
$ git pull
1706
1705
-------------------------------------------------
1707
1706
1708
- See the descriptions of the branch.<name>.remote and
1709
- branch.<name>.merge options in gitlink:git-config[1] to learn
1710
- how to control these defaults depending on the current branch.
1707
+ See the descriptions of the branch.<name>.remote and branch.<name>.merge
1708
+ options in gitlink:git-config[1] to learn how to control these defaults
1709
+ depending on the current branch. Also note that the --track option to
1710
+ gitlink:git-branch[1] and gitlink:git-checkout[1] can be used to
1711
+ automatically set the default remote branch to pull from at the time
1712
+ that a branch is created:
1713
+
1714
+ -------------------------------------------------
1715
+ $ git checkout --track -b origin/maint maint
1716
+ -------------------------------------------------
1711
1717
1712
1718
In addition to saving you keystrokes, "git pull" also helps you by
1713
1719
producing a default commit message documenting the branch and
@@ -1830,14 +1836,14 @@ Now, assume your personal repository is in the directory ~/proj. We
1830
1836
first create a new clone of the repository:
1831
1837
1832
1838
-------------------------------------------------
1833
- $ git clone --bare proj-clone .git
1839
+ $ git clone --bare proj.git
1834
1840
-------------------------------------------------
1835
1841
1836
- The resulting directory proj-clone .git will contains a "bare" git
1842
+ The resulting directory proj.git will contains a "bare" git
1837
1843
repository--it is just the contents of the ".git" directory, without
1838
1844
a checked-out copy of a working directory.
1839
1845
1840
- Next, copy proj-clone .git to the server where you plan to host the
1846
+ Next, copy proj.git to the server where you plan to host the
1841
1847
public repository. You can use scp, rsync, or whatever is most
1842
1848
convenient.
1843
1849
@@ -1863,7 +1869,7 @@ adjustments to give web clients some extra information they need:
1863
1869
-------------------------------------------------
1864
1870
$ mv proj.git /home/you/public_html/proj.git
1865
1871
$ cd proj.git
1866
- $ git update-server-info
1872
+ $ git --bare update-server-info
1867
1873
$ chmod a+x hooks/post-update
1868
1874
-------------------------------------------------
1869
1875
@@ -1930,7 +1936,7 @@ As with git-fetch, you may also set up configuration options to
1930
1936
save typing; so, for example, after
1931
1937
1932
1938
-------------------------------------------------
1933
- $ cat >.git/config <<EOF
1939
+ $ cat >> .git/config <<EOF
1934
1940
[remote "public-repo"]
1935
1941
url = ssh://yourserver.com/~you/proj.git
1936
1942
EOF
@@ -2312,9 +2318,15 @@ descendant of the old head, you may force the update with:
2312
2318
$ git fetch git://example.com/proj.git +master:refs/remotes/example/master
2313
2319
-------------------------------------------------
2314
2320
2315
- Note the addition of the "+" sign. Be aware that commits that the
2316
- old version of example/master pointed at may be lost, as we saw in
2317
- the previous section.
2321
+ Note the addition of the "+" sign. Alternatively, you can use the "-f"
2322
+ flag to force updates of all the fetched branches, as in:
2323
+
2324
+ -------------------------------------------------
2325
+ $ git fetch -f origin
2326
+ -------------------------------------------------
2327
+
2328
+ Be aware that commits that the old version of example/master pointed at
2329
+ may be lost, as we saw in the previous section.
2318
2330
2319
2331
[[remote-branch-configuration]]
2320
2332
Configuring remote branches
@@ -2400,7 +2412,7 @@ approximated by the SHA1 hash of the object itself. Objects may refer
2400
2412
to other objects (by referencing their SHA1 hash), and so you can
2401
2413
build up a hierarchy of objects.
2402
2414
2403
- All objects have a statically determined "type" aka "tag", which is
2415
+ All objects have a statically determined "type" which is
2404
2416
determined at object creation time, and which identifies the format of
2405
2417
the object (i.e. how it is used, and how it can refer to other
2406
2418
objects). There are currently four different object types: "blob",
@@ -2423,7 +2435,7 @@ the time of the commit). In addition, a "commit" refers to one or more
2423
2435
that directory hierarchy.
2424
2436
2425
2437
As a special case, a commit object with no parents is called the "root"
2426
- object , and is the point of an initial project commit. Each project
2438
+ commit , and is the point of an initial project commit. Each project
2427
2439
must have at least one root, and while you can tie several different
2428
2440
root objects together into one project by creating a commit object which
2429
2441
has two or more separate roots as its ultimate parents, that's probably
@@ -2542,7 +2554,7 @@ that the tree is "good" or that the merge information makes sense.
2542
2554
The parents do not have to actually have any relationship with the
2543
2555
result, for example.
2544
2556
2545
- Note on commits: unlike real SCM's, commits do not contain
2557
+ Note on commits: unlike some SCM's, commits do not contain
2546
2558
rename information or file mode change information. All of that is
2547
2559
implicit in the trees involved (the result tree, and the result trees
2548
2560
of the parents), and describing that makes no sense in this idiotic
@@ -2609,7 +2621,7 @@ The "index" aka "Current Directory Cache"
2609
2621
-----------------------------------------
2610
2622
2611
2623
The index is a simple binary file, which contains an efficient
2612
- representation of a virtual directory content at some random time . It
2624
+ representation of the contents of a virtual directory . It
2613
2625
does so by a simple array that associates a set of names, dates,
2614
2626
permissions and content (aka "blob") objects together. The cache is
2615
2627
always kept ordered by name, and names are unique (with a few very
@@ -2912,7 +2924,7 @@ since the tree object information is always the first line in a commit
2912
2924
object.
2913
2925
2914
2926
Once you know the three trees you are going to merge (the one "original"
2915
- tree, aka the common case , and the two "result" trees, aka the branches
2927
+ tree, aka the common tree , and the two "result" trees, aka the branches
2916
2928
you want to merge), you do a "merge" read into the index. This will
2917
2929
complain if it has to throw away your old index contents, so you should
2918
2930
make sure that you've committed those - in fact you would normally
@@ -2966,14 +2978,14 @@ obviously the final outcome is what is in `HEAD`. What the
2966
2978
above example shows is that file `hello.c` was changed from
2967
2979
`$orig` to `HEAD` and `$orig` to `$target` in a different way.
2968
2980
You could resolve this by running your favorite 3-way merge
2969
- program, e.g. `diff3` or `merge`, on the blob objects from
2970
- these three stages yourself, like this:
2981
+ program, e.g. `diff3`, `merge`, or git's own merge-file, on
2982
+ the blob objects from these three stages yourself, like this:
2971
2983
2972
2984
------------------------------------------------
2973
2985
$ git-cat-file blob 263414f... >hello.c~1
2974
2986
$ git-cat-file blob 06fa6a2... >hello.c~2
2975
2987
$ git-cat-file blob cc44c73... >hello.c~3
2976
- $ merge hello.c~2 hello.c~1 hello.c~3
2988
+ $ git merge-file hello.c~2 hello.c~1 hello.c~3
2977
2989
------------------------------------------------
2978
2990
2979
2991
This would leave the merge result in `hello.c~2` file, along
0 commit comments