@matheusbsbs / matheus-bagliano / commits / f2416c27ef
Fork 0

Use consistent shell prompts and example style.

Signed-off-by: Jon Loeliger <jdl@freescale.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jon Loeliger committed Nov 7, 2005 at 08:33 UTC f2416c27effb4da4f6558b6f8dd66843948405af
1 file changed +138 -88
Documentation/tutorial.txt
+138 -88
@@ -36,14 +36,16 @@ To start up, create a subdirectory for it, change into that
36 subdirectory, and initialize the git infrastructure with `git-init-db`:
37
38 ------------------------------------------------
39 -mkdir git-tutorial
40 -cd git-tutorial
41 -git-init-db
39 +$ mkdir git-tutorial
40 +$ cd git-tutorial
41 +$ git-init-db
42 ------------------------------------------------
43
44 to which git will reply
45
46 - defaulting to local storage area
46 +----------------
47 +defaulting to local storage area
48 +----------------
49
50 which is just git's way of saying that you haven't been doing anything
51 strange, and that it will have created a local `.git` directory setup for
@@ -114,8 +116,8 @@ in your git repository. We'll start off with a few bad examples, just to
116 get a feel for how this works:
117
118 ------------------------------------------------
117 -echo "Hello World" >hello
118 -echo "Silly example" >example
119 +$ echo "Hello World" >hello
120 +$ echo "Silly example" >example
121 ------------------------------------------------
122
123 you have now created two files in your working tree (aka 'working directory'), but to
@@ -137,7 +139,7 @@ adding a new entry with the `\--add` flag (or removing an entry with the
139 So to populate the index with the two files you just created, you can do
140
141 ------------------------------------------------
140 -git-update-index --add hello example
142 +$ git-update-index --add hello example
143 ------------------------------------------------
144
145 and you have now told git to track those two files.
@@ -146,12 +148,17 @@ In fact, as you did that, if you now look into your object directory,
148 you'll notice that git will have added two new objects to the object
149 database. If you did exactly the steps above, you should now be able to do
150
149 - ls .git/objects/??/*
151 +
152 +----------------
153 +$ ls .git/objects/??/*
154 +----------------
155
156 and see two files:
157
153 - .git/objects/55/7db03de997c86a4a028e1ebd3a1ceb225be238
154 - .git/objects/f2/4c74a2e500f5ee1332c86b94199f52b1d1d962
158 +----------------
159 +.git/objects/55/7db03de997c86a4a028e1ebd3a1ceb225be238
160 +.git/objects/f2/4c74a2e500f5ee1332c86b94199f52b1d1d962
161 +----------------
162
163 which correspond with the objects with names of 557db... and f24c7..
164 respectively.
@@ -159,13 +166,17 @@ respectively.
166 If you want to, you can use `git-cat-file` to look at those objects, but
167 you'll have to use the object name, not the filename of the object:
168
162 - git-cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238
169 +----------------
170 +$ git-cat-file -t 557db03de997c86a4a028e1ebd3a1ceb225be238
171 +----------------
172
173 where the `-t` tells `git-cat-file` to tell you what the "type" of the
174 object is. git will tell you that you have a "blob" object (ie just a
175 regular file), and you can see the contents with
176
168 - git-cat-file "blob" 557db03
177 +----------------
178 +$ git-cat-file "blob" 557db03
179 +----------------
180
181 which will print out "Hello World". The object 557db03 is nothing
182 more than the contents of your file `hello`.
@@ -202,7 +213,7 @@ In particular, let's not even check in the two files into git yet, we'll
213 start off by adding another line to `hello` first:
214
215 ------------------------------------------------
205 -echo "It's a new day for git" >>hello
216 +$ echo "It's a new day for git" >>hello
217 ------------------------------------------------
218
219 and you can now, since you told git about the previous state of `hello`, ask
@@ -210,7 +221,7 @@ git what has changed in the tree compared to your old index, using the
221 `git-diff-files` command:
222
223 ------------
213 -git-diff-files
224 +$ git-diff-files
225 ------------
226
227 Oops. That wasn't very readable. It just spit out its own internal
@@ -222,12 +233,7 @@ To make it readable, we can tell git-diff-files to output the
233 differences as a patch, using the `-p` flag:
234
235 ------------
225 -git-diff-files -p
226 -------------
227 -
228 -which will spit out
229 -
230 -------------
236 +$ git-diff-files -p
237 diff --git a/hello b/hello
238 index 557db03..263414f 100644
239 --- a/hello
@@ -264,13 +270,15 @@ filenames with their contents (and their permissions), and we're
270 creating the equivalent of a git "directory" object:
271
272 ------------------------------------------------
267 -git-write-tree
273 +$ git-write-tree
274 ------------------------------------------------
275
276 and this will just output the name of the resulting tree, in this case
277 (if you have done exactly as I've described) it should be
278
273 - 8988da15d077d4829fc51d8544c097def6644dbb
279 +----------------
280 +8988da15d077d4829fc51d8544c097def6644dbb
281 +----------------
282
283 which is another incomprehensible object name. Again, if you want to,
284 you can use `git-cat-file -t 8988d\...` to see that this time the object
@@ -299,14 +307,16 @@ that's exactly what `git-commit-tree` spits out, we can do this
307 all with a sequence of simple shell commands:
308
309 ------------------------------------------------
302 -tree=$(git-write-tree)
303 -commit=$(echo 'Initial commit' | git-commit-tree $tree)
304 -git-update-ref HEAD $commit
310 +$ tree=$(git-write-tree)
311 +$ commit=$(echo 'Initial commit' | git-commit-tree $tree)
312 +$ git-update-ref HEAD $commit
313 ------------------------------------------------
314
315 which will say:
316
309 - Committing initial tree 8988da15d077d4829fc51d8544c097def6644dbb
317 +----------------
318 +Committing initial tree 8988da15d077d4829fc51d8544c097def6644dbb
319 +----------------
320
321 just to warn you about the fact that it created a totally new commit
322 that is not related to anything else. Normally you do this only *once*
@@ -349,7 +359,9 @@ didn't have anything to diff against.
359
360 But now we can do
361
352 - git-diff-index -p HEAD
362 +----------------
363 +$ git-diff-index -p HEAD
364 +----------------
365
366 (where `-p` has the same meaning as it did in `git-diff-files`), and it
367 will show us the same difference, but for a totally different reason.
@@ -360,7 +372,9 @@ are obviously the same, so we get the same result.
372 Again, because this is a common operation, you can also just shorthand
373 it with
374
363 - git diff HEAD
375 +----------------
376 +$ git diff HEAD
377 +----------------
378
379 which ends up doing the above for you.
380
@@ -396,7 +410,7 @@ work through the index file, so the first thing we need to do is to
410 update the index cache:
411
412 ------------------------------------------------
399 -git-update-index hello
413 +$ git-update-index hello
414 ------------------------------------------------
415
416 (note how we didn't need the `\--add` flag this time, since git knew
@@ -417,7 +431,7 @@ this wasn't an initial commit any more), but you've done that once
431 already, so let's just use the helpful script this time:
432
433 ------------------------------------------------
420 -git commit
434 +$ git commit
435 ------------------------------------------------
436
437 which starts an editor for you to write the commit message and tells you
@@ -450,7 +464,9 @@ give it just a single commit object, and it will figure out the parent
464 of that commit itself, and show the difference directly. Thus, to get
465 the same diff that we've already seen several times, we can now do
466
453 - git-diff-tree -p HEAD
467 +----------------
468 +$ git-diff-tree -p HEAD
469 +----------------
470
471 (again, `-p` means to show the difference as a human-readable patch),
472 and it will show what the last commit (in `HEAD`) actually changed.
@@ -505,13 +521,17 @@ activities.
521 To see the whole history of our pitiful little git-tutorial project, you
522 can do
523
508 - git log
524 +----------------
525 +$ git log
526 +----------------
527
528 which shows just the log messages, or if we want to see the log together
529 with the associated patches use the more complex (and much more
530 powerful)
531
514 - git-whatchanged -p --root
532 +----------------
533 +$ git-whatchanged -p --root
534 +----------------
535
536 and you will see exactly what has changed in the repository over its
537 short history.
@@ -547,14 +567,16 @@ it in the `.git/refs/tags/` subdirectory instead of calling it a `head`.
567 So the simplest form of tag involves nothing more than
568
569 ------------------------------------------------
550 -git tag my-first-tag
570 +$ git tag my-first-tag
571 ------------------------------------------------
572
573 which just writes the current `HEAD` into the `.git/refs/tags/my-first-tag`
574 file, after which point you can then use this symbolic name for that
575 particular state. You can, for example, do
576
557 - git diff my-first-tag
577 +----------------
578 +$ git diff my-first-tag
579 +----------------
580
581 to diff your current state against that tag (which at this point will
582 obviously be an empty diff, but if you continue to develop and commit
@@ -568,7 +590,9 @@ you really did
590 that tag. You create these annotated tags with either the `-a` or
591 `-s` flag to `git tag`:
592
571 - git tag -s <tagname>
593 +----------------
594 +$ git tag -s <tagname>
595 +----------------
596
597 which will sign the current `HEAD` (but you can also give it another
598 argument that specifies the thing to tag, ie you could have tagged the
@@ -584,8 +608,8 @@ name for the state at that point.
608 Copying repositories
609 --------------------
610
587 -git repositories are normally totally self-sufficient, and it's worth noting
588 -that unlike CVS, for example, there is no separate notion of
611 +git repositories are normally totally self-sufficient and relocatable
612 +Unlike CVS, for example, there is no separate notion of
613 "repository" and "working tree". A git repository normally *is* the
614 working tree, with the local git information hidden in the `.git`
615 subdirectory. There is nothing else. What you see is what you got.
@@ -602,8 +626,10 @@ This has two implications:
626
627 - if you grow bored with the tutorial repository you created (or you've
628 made a mistake and want to start all over), you can just do simple
605 -
606 - rm -rf git-tutorial
629 ++
630 +----------------
631 +$ rm -rf git-tutorial
632 +----------------
633 +
634 and it will be gone. There's no external repository, and there's no
635 history outside the project you created.
@@ -618,8 +644,10 @@ Note that when you've moved or copied a git repository, your git index
644 file (which caches various information, notably some of the "stat"
645 information for the files involved) will likely need to be refreshed.
646 So after you do a `cp -a` to create a new copy, you'll want to do
621 -
622 - git-update-index --refresh
647 ++
648 +----------------
649 +$ git-update-index --refresh
650 +----------------
651 +
652 in the new repository to make sure that the index file is up-to-date.
653
@@ -633,8 +661,10 @@ repositories you often want to make sure that the index cache is in some
661 known state (you don't know *what* they've done and not yet checked in),
662 so usually you'll precede the `git-update-index` with a
663
636 - git-read-tree --reset HEAD
637 - git-update-index --refresh
664 +----------------
665 +$ git-read-tree --reset HEAD
666 +$ git-update-index --refresh
667 +----------------
668
669 which will force a total index re-build from the tree pointed to by `HEAD`.
670 It resets the index contents to `HEAD`, and then the `git-update-index`
@@ -645,7 +675,9 @@ tells you they need to be updated.
675
676 The above can also be written as simply
677
648 - git reset
678 +----------------
679 +$ git reset
680 +----------------
681
682 and in fact a lot of the common git command combinations can be scripted
683 with the `git xyz` interfaces. You can learn things by just looking
@@ -665,20 +697,26 @@ first create your own subdirectory for the project, and then copy the
697 raw repository contents into the `.git` directory. For example, to
698 create your own copy of the git repository, you'd do the following
699
668 - mkdir my-git
669 - cd my-git
670 - rsync -rL rsync://rsync.kernel.org/pub/scm/git/git.git/ .git
700 +----------------
701 +$ mkdir my-git
702 +$ cd my-git
703 +$ rsync -rL rsync://rsync.kernel.org/pub/scm/git/git.git/ .git
704 +----------------
705
706 followed by
707
674 - git-read-tree HEAD
708 +----------------
709 +$ git-read-tree HEAD
710 +----------------
711
712 to populate the index. However, now you have populated the index, and
713 you have all the git internal files, but you will notice that you don't
714 actually have any of the working tree files to work on. To get
715 those, you'd check them out with
716
681 - git-checkout-index -u -a
717 +----------------
718 +$ git-checkout-index -u -a
719 +----------------
720
721 where the `-u` flag means that you want the checkout to keep the index
722 up-to-date (so that you don't have to refresh it afterward), and the
@@ -689,9 +727,11 @@ files).
727
728 Again, this can all be simplified with
729
692 - git clone rsync://rsync.kernel.org/pub/scm/git/git.git/ my-git
693 - cd my-git
694 - git checkout
730 +----------------
731 +$ git clone rsync://rsync.kernel.org/pub/scm/git/git.git/ my-git
732 +$ cd my-git
733 +$ git checkout
734 +----------------
735
736 which will end up doing all of the above for you.
737
@@ -719,7 +759,7 @@ used earlier, and create a branch in it. You do that by simply just
759 saying that you want to check out a new branch:
760
761 ------------
722 -git checkout -b mybranch
762 +$ git checkout -b mybranch
763 ------------
764
765 will create a new branch based at the current `HEAD` position, and switch
@@ -733,7 +773,7 @@ just telling `git checkout` what the base of the checkout would be.
773 In other words, if you have an earlier tag or branch, you'd just do
774
775 ------------
736 -git checkout -b mybranch earlier-commit
776 +$ git checkout -b mybranch earlier-commit
777 ------------
778
779 and it would create the new branch `mybranch` at the earlier commit,
@@ -743,27 +783,27 @@ and check out the state at that time.
783 You can always just jump back to your original `master` branch by doing
784
785 ------------
746 -git checkout master
786 +$ git checkout master
787 ------------
788
789 (or any other branch-name, for that matter) and if you forget which
790 branch you happen to be on, a simple
791
792 ------------
753 -ls -l .git/HEAD
793 +$ ls -l .git/HEAD
794 ------------
795
796 will tell you where it's pointing (Note that on platforms with bad or no
797 symlink support, you have to execute
798
799 ------------
760 -cat .git/HEAD
800 +$ cat .git/HEAD
801 ------------
802
803 instead). To get the list of branches you have, you can say
804
805 ------------
766 -git branch
806 +$ git branch
807 ------------
808
809 which is nothing more than a simple script around `ls .git/refs/heads`.
@@ -773,7 +813,7 @@ Sometimes you may wish to create a new branch _without_ actually
813 checking it out and switching to it. If so, just use the command
814
815 ------------
776 -git branch <branchname> [startingpoint]
816 +$ git branch <branchname> [startingpoint]
817 ------------
818
819 which will simply _create_ the branch, but will not do anything further.
@@ -792,9 +832,9 @@ being the same as the original `master` branch, let's make sure we're in
832 that branch, and do some work there.
833
834 ------------------------------------------------
795 -git checkout mybranch
796 -echo "Work, work, work" >>hello
797 -git commit -m 'Some work.' hello
835 +$ git checkout mybranch
836 +$ echo "Work, work, work" >>hello
837 +$ git commit -m 'Some work.' hello
838 ------------------------------------------------
839
840 Here, we just added another line to `hello`, and we used a shorthand for
@@ -807,7 +847,7 @@ does some work in the original branch, and simulate that by going back
847 to the master branch, and editing the same file differently there:
848
849 ------------
810 -git checkout master
850 +$ git checkout master
851 ------------
852
853 Here, take a moment to look at the contents of `hello`, and notice how they
@@ -815,9 +855,9 @@ don't contain the work we just did in `mybranch` -- because that work
855 hasn't happened in the `master` branch at all. Then do
856
857 ------------
818 -echo "Play, play, play" >>hello
819 -echo "Lots of fun" >>example
820 -git commit -m 'Some fun.' hello example
858 +$ echo "Play, play, play" >>hello
859 +$ echo "Lots of fun" >>example
860 +$ git commit -m 'Some fun.' hello example
861 ------------
862
863 since the master branch is obviously in a much better mood.
@@ -826,7 +866,9 @@ Now, you've got two branches, and you decide that you want to merge the
866 work done. Before we do that, let's introduce a cool graphical tool that
867 helps you view what's going on:
868
829 - gitk --all
869 +----------------
870 +$ gitk --all
871 +----------------
872
873 will show you graphically both of your branches (that's what the `\--all`
874 means: normally it will just show you your current `HEAD`) and their
@@ -840,7 +882,7 @@ script called `git merge`, which wants to know which branches you want
882 to resolve and what the merge is all about:
883
884 ------------
843 -git merge "Merge work in mybranch" HEAD mybranch
885 +$ git merge "Merge work in mybranch" HEAD mybranch
886 ------------
887
888 where the first argument is going to be used as the commit message if
@@ -851,6 +893,7 @@ merge will need to be fixed up by hand, though, so git will do as much
893 of it as it can automatically (which in this case is just merge the `example`
894 file, which had no differences in the `mybranch` branch), and say:
895
896 +----------------
897 Trying really trivial in-index merge...
898 fatal: Merge requires file-level merging
899 Nope.
@@ -859,6 +902,7 @@ file, which had no differences in the `mybranch` branch), and say:
902 ERROR: Merge conflict in hello.
903 fatal: merge program failed
904 Automatic merge failed/prevented; fix up by hand
905 +----------------
906
907 which is way too verbose, but it basically tells you that it failed the
908 really trivial merge ("Simple merge") and did an "Automatic merge"
@@ -879,7 +923,7 @@ Work, work, work
923 and once you're happy with your manual merge, just do a
924
925 ------------
882 -git commit hello
926 +$ git commit hello
927 ------------
928
929 which will very loudly warn you that you're now committing a merge
@@ -929,17 +973,19 @@ to the `master` branch. Let's go back to `mybranch`, and run
973 resolve to get the "upstream changes" back to your branch.
974
975 ------------
932 -git checkout mybranch
933 -git merge "Merge upstream changes." HEAD master
976 +$ git checkout mybranch
977 +$ git merge "Merge upstream changes." HEAD master
978 ------------
979
980 This outputs something like this (the actual commit object names
981 would be different)
982
939 - Updating from ae3a2da... to a80b4aa....
940 - example | 1 +
941 - hello | 1 +
942 - 2 files changed, 2 insertions(+), 0 deletions(-)
983 +----------------
984 +Updating from ae3a2da... to a80b4aa....
985 + example | 1 +
986 + hello | 1 +
987 + 2 files changed, 2 insertions(+), 0 deletions(-)
988 +----------------
989
990 Because your branch did not contain anything more than what are
991 already merged into the `master` branch, the resolve operation did
@@ -972,7 +1018,9 @@ followed by a `git merge`.
1018 Fetching from a remote repository is done by, unsurprisingly,
1019 `git fetch`:
1020
975 - git fetch <remote-repository>
1021 +----------------
1022 +$ git fetch <remote-repository>
1023 +----------------
1024
1025 One of the following transports can be used to name the
1026 repository to download from:
@@ -1017,7 +1065,7 @@ This transport was designed for anonymous downloading. Like SSH
1065 transport, it finds out the set of objects the downstream side
1066 lacks and transfers (close to) minimum set of objects.
1067
1020 -HTTP(s)::
1068 +HTTP(S)::
1069 `http://remote.machine/path/to/repo.git/`
1070 +
1071 HTTP and HTTPS transport are used only for downloading. They
@@ -1047,7 +1095,9 @@ However -- it's such a common thing to `fetch` and then
1095 immediately `resolve`, that it's called `git pull`, and you can
1096 simply do
1097
1050 - git pull <remote-repository>
1098 +----------------
1099 +$ git pull <remote-repository>
1100 +----------------
1101
1102 and optionally give a branch-name for the remote end as a second
1103 argument.
@@ -1075,8 +1125,8 @@ the remote repository URL in a file under .git/remotes/
1125 directory, like this:
1126
1127 ------------------------------------------------
1078 -mkdir -p .git/remotes/
1079 -cat >.git/remotes/linus <<\EOF
1128 +$ mkdir -p .git/remotes/
1129 +$ cat >.git/remotes/linus <<\EOF
1130 URL: http://www.kernel.org/pub/scm/git/git.git/
1131 EOF
1132 ------------------------------------------------
@@ -1086,7 +1136,7 @@ The URL specified in such file can even be a prefix
1136 of a full URL, like this:
1137
1138 ------------------------------------------------
1089 -cat >.git/remotes/jgarzik <<\EOF
1139 +$ cat >.git/remotes/jgarzik <<\EOF
1140 URL: http://www.kernel.org/pub/scm/linux/git/jgarzik/
1141 EOF
1142 ------------------------------------------------
@@ -1300,7 +1350,7 @@ project `my-git`. After logging into the remote machine, create
1350 an empty directory:
1351
1352 ------------
1303 -mkdir my-git.git
1353 +$ mkdir my-git.git
1354 ------------
1355
1356 Then, make that directory into a git repository by running
@@ -1308,7 +1358,7 @@ Then, make that directory into a git repository by running
1358 `.git`, we do things slightly differently:
1359
1360 ------------
1311 -GIT_DIR=my-git.git git-init-db
1361 +$ GIT_DIR=my-git.git git-init-db
1362 ------------
1363
1364 Make sure this directory is available for others you want your
@@ -1334,7 +1384,7 @@ Come back to the machine you have your private repository. From
1384 there, run this command:
1385
1386 ------------
1337 -git push <public-host>:/path/to/my-git.git master
1387 +$ git push <public-host>:/path/to/my-git.git master
1388 ------------
1389
1390 This synchronizes your public repository to match the named
@@ -1346,7 +1396,7 @@ repository. Kernel.org mirror network takes care of the
1396 propagation to other publicly visible machines:
1397
1398 ------------
1349 -git push master.kernel.org:/pub/scm/git/git.git/
1399 +$ git push master.kernel.org:/pub/scm/git/git.git/
1400 ------------
1401
1402
@@ -1361,7 +1411,7 @@ immutable once they are created, there is a way to optimize the
1411 storage by "packing them together". The command
1412
1413 ------------
1364 -git repack
1414 +$ git repack
1415 ------------
1416
1417 will do it for you. If you followed the tutorial examples, you
@@ -1387,7 +1437,7 @@ Once you have packed objects, you do not need to leave the
1437 unpacked objects that are contained in the pack file anymore.
1438
1439 ------------
1390 -git prune-packed
1440 +$ git prune-packed
1441 ------------
1442
1443 would remove them for you.