Information Technology Reference
In-Depth Information
The [REVISION] parameter defines where a new branch would point to. If you
omit this parameter, HEAD will be used. Thus, both commands:
$ git branch new-name
$ git branch new-name HEAD
are equivalent. The same is true for other commands as well. The following two com-
mands are also equivalent:
$ git checkout -b new-branch
$ git checkout -b new-branch HEAD
Notice The special name HEAD is transformed to a path .git/HEAD . Therefore, if
you work on u*ix-like systems you have to type it using capital letters. Readers working
on Windows can type HEAD using lower case (i.e., head ).
The revisions can be identified in many different ways. You already know that both
SHA-1 and abbreviated SHA-1 names can be used. The other ways to reference revi-
sions include branches, reflog entries, ancestor references, n-th parent references, and
tags. Here are some more examples how to create branches pointing to particular revi-
sions:
$ git branch new-branch info # existing branch
$ git branch new-branch a1b2c3ef # abbreviated SHA-1
$ git branch new-branch HEAD@{5} # reflog entry
$ git branch new-branch doc 5 # ancestor reference
$ git branch new-branch master^2 # n-th parent reference
$ git branch new-branch v1.2.3
# tag
Keep in mind, that the above commands do not modify a database stored in .git/ob-
jects. They only create a file in .git/refs/heads . This file will contain a SHA-1
of a given revision.
Hint The syntax for the $ git checkout -b command can also be written in a
more general form as $ git checkout -b new-branch [REVISION]
Search WWH ::




Custom Search