Information Technology Reference
In-Depth Information
to display all branches: $ git log --oneline --graph --decorate --
all .
How It Works
The recipe uses two important commands:
$ git cherry-pick doc
$ git reset --hard HEAD
The first command— cherry-pick —makes a copy of a given revision in a cur-
rent branch. It needs a single parameter that points to the revision to be copied. If you
pass a name of the branch to this command, it will copy the revision pointed to by the
branch; that is, the tip of the branch. You can use other means to identify a revision, as
well, for example:
$ git cherry-pick 7c9bc41
# shortened SHA-1 name
$ git cherry-pick info
# last but one commit in
info branch
$ git cherry-pick info 3
# branch name and ancestor
reference
The term to copy a revision can be a little misleading here. Every revision you cre-
ate has a unique name. There are no exemptions from this rule. You can only:
• Add new revisions to the git's database
• Remove existing revisions from the git's database
Git doesn't implement modification of objects stored in a database. The name of the
commit is a SHA-1 hash, which was produced using your name, current timestamp, the
snapshot of your files, and the name of the parent revision. When we copy a revision
from one place in the history to another we change at least one of these parameters: the
name of the parent revision. As a result there is no way to preserve the old SHA-1 for a
copied revision. Thus the operation realized by cherry-pick command can be bet-
ter described as applying the changes introduced by a given revision on top of your
current branch. The command creates a completely new revision that reproduces the
Search WWH ::




Custom Search