@@ -51,7 +51,9 @@ your new project. You will now have a `.git` directory, and you can
5151inspect that with `ls`. For your new empty project, it should show you
5252three entries, among other things:
5353
54- - a symlink called `HEAD`, pointing to `refs/heads/master`
54+ - a symlink called `HEAD`, pointing to `refs/heads/master` (if your
55+ platform does not have native symlinks, it is a file containing the
56+ line "ref: refs/heads/master")
5557+
5658Don't worry about the fact that the file that the `HEAD` link points to
5759doesn't even exist yet -- you haven't created the commit that will
@@ -227,6 +229,7 @@ which will spit out
227229
228230------------
229231diff --git a/hello b/hello
232+ index 557db03..263414f 100644
230233--- a/hello
231234+++ b/hello
232235@@ -1 +1,2 @@
@@ -289,13 +292,16 @@ also wants to get a commit message
289292on its standard input, and it will write out the resulting object name for the
290293commit to its standard output.
291294
292- And this is where we start using the `.git/HEAD` file. The `HEAD` file is
293- supposed to contain the reference to the top-of-tree, and since that's
294- exactly what `git-commit-tree` spits out, we can do this all with a simple
295- shell pipeline:
295+ And this is where we create the `.git/refs/heads/master` file
296+ which is pointed at by `HEAD`. This file is supposed to contain
297+ the reference to the top-of-tree of the master branch, and since
298+ that's exactly what `git-commit-tree` spits out, we can do this
299+ all with a sequence of simple shell commands:
296300
297301------------------------------------------------
298- echo "Initial commit" | git-commit-tree $(git-write-tree) > .git/HEAD
302+ tree=$(git-write-tree)
303+ commit=$(echo 'Initial commit' | git-commit-tree $tree)
304+ git-update-ref HEAD $(commit)
299305------------------------------------------------
300306
301307which will say:
@@ -691,33 +697,49 @@ other point in the history than the current `HEAD`, you can do so by
691697just telling `git checkout` what the base of the checkout would be.
692698In other words, if you have an earlier tag or branch, you'd just do
693699
694- git checkout -b mybranch earlier-commit
700+ ------------
701+ git checkout -b mybranch earlier-commit
702+ ------------
695703
696704and it would create the new branch `mybranch` at the earlier commit,
697705and check out the state at that time.
698706================================================
699707
700708You can always just jump back to your original `master` branch by doing
701709
702- git checkout master
710+ ------------
711+ git checkout master
712+ ------------
703713
704714(or any other branch-name, for that matter) and if you forget which
705715branch you happen to be on, a simple
706716
707- ls -l .git/HEAD
717+ ------------
718+ ls -l .git/HEAD
719+ ------------
708720
709- will tell you where it's pointing. To get the list of branches
710- you have , you can say
721+ will tell you where it's pointing (Note that on platforms with bad or no
722+ symlink support , you have to execute
711723
712- git branch
724+ ------------
725+ cat .git/HEAD
726+ ------------
727+
728+ instead). To get the list of branches you have, you can say
729+
730+ ------------
731+ git branch
732+ ------------
713733
714734which is nothing more than a simple script around `ls .git/refs/heads`.
715735There will be asterisk in front of the branch you are currently on.
716736
717737Sometimes you may wish to create a new branch _without_ actually
718738checking it out and switching to it. If so, just use the command
719739
720- git branch <branchname> [startingpoint]
740+ ------------
741+ git branch <branchname> [startingpoint]
742+ ------------
721743
722744which will simply _create_ the branch, but will not do anything further.
723745You can then later -- once you decide that you want to actually develop
@@ -843,7 +865,6 @@ $ git show-branch master mybranch
843865 ! [mybranch] Some work.
844866--
845867+ [master] Merged "mybranch" changes.
846- + [master~1] Some fun.
847868++ [mybranch] Some work.
848869------------------------------------------------
849870
@@ -870,8 +891,10 @@ Now, let's pretend you are the one who did all the work in
870891to the `master` branch. Let's go back to `mybranch`, and run
871892resolve to get the "upstream changes" back to your branch.
872893
873- git checkout mybranch
874- git resolve HEAD master "Merge upstream changes."
894+ ------------
895+ git checkout mybranch
896+ git resolve HEAD master "Merge upstream changes."
897+ ------------
875898
876899This outputs something like this (the actual commit object names
877900would be different)
@@ -1087,13 +1110,17 @@ i.e. `<project>.git`. Let's create such a public repository for
10871110project `my-git`. After logging into the remote machine, create
10881111an empty directory:
10891112
1090- mkdir my-git.git
1113+ ------------
1114+ mkdir my-git.git
1115+ ------------
10911116
10921117Then, make that directory into a git repository by running
10931118`git init-db`, but this time, since its name is not the usual
10941119`.git`, we do things slightly differently:
10951120
1096- GIT_DIR=my-git.git git-init-db
1121+ ------------
1122+ GIT_DIR=my-git.git git-init-db
1123+ ------------
10971124
10981125Make sure this directory is available for others you want your
10991126changes to be pulled by via the transport of your choice. Also
@@ -1117,7 +1144,9 @@ Your "public repository" is now ready to accept your changes.
11171144Come back to the machine you have your private repository. From
11181145there, run this command:
11191146
1120- git push <public-host>:/path/to/my-git.git master
1147+ ------------
1148+ git push <public-host>:/path/to/my-git.git master
1149+ ------------
11211150
11221151This synchronizes your public repository to match the named
11231152branch head (i.e. `master` in this case) and objects reachable
@@ -1127,7 +1156,9 @@ As a real example, this is how I update my public git
11271156repository. Kernel.org mirror network takes care of the
11281157propagation to other publicly visible machines:
11291158
1130- git push master.kernel.org:/pub/scm/git/git.git/
1159+ ------------
1160+ git push master.kernel.org:/pub/scm/git/git.git/
1161+ ------------
11311162
11321163
11331164Packing your repository
@@ -1140,7 +1171,9 @@ not so convenient to transport over the network. Since git objects are
11401171immutable once they are created, there is a way to optimize the
11411172storage by "packing them together". The command
11421173
1143- git repack
1174+ ------------
1175+ git repack
1176+ ------------
11441177
11451178will do it for you. If you followed the tutorial examples, you
11461179would have accumulated about 17 objects in `.git/objects/??/`
@@ -1164,7 +1197,9 @@ Our programs are always perfect ;-).
11641197Once you have packed objects, you do not need to leave the
11651198unpacked objects that are contained in the pack file anymore.
11661199
1167- git prune-packed
1200+ ------------
1201+ git prune-packed
1202+ ------------
11681203
11691204would remove them for you.
11701205
0 commit comments