[英]How to interpret the brackets in the git log?
Running git log
gives me an output like this: 运行
git log
给我这样的输出:
commit 69b6309f09365c09a2fe10f09aee801d1fae29ee (HEAD -> master, edeviserBranch)
Author: eDeviser <eDeviser@xyz.com>
Date: Mon Sep 2 09:53:07 2019 +0200
added foo
commit 59a08270fb730db259a8d5819bb585a613024d97 (origin/master, origin/HEAD)
Author: eDeviser <eDeviser@xyz.com>
Date: Mon Sep 2 09:49:50 2019 +0200
More Text
I don't understand the meaning of the content inside the brackets. 我不明白方括号内内容的含义。 What is the meaning of the text inside the brackets?
方括号内的文字是什么意思? Is this the branch which is the commit based on?
这是提交所基于的分支吗? If yes, what is the difference between
HEAD -> master
, origin/master
and origin/HEAD
? 如果是,那么
HEAD -> master
, origin/master
和origin/HEAD
什么区别?
How to interpret the brackets in the git log? 如何解释git日志中的括号?
HEAD remembers the branch location HEAD-> master is where you work HEAD记住分支位置HEAD-> master是您工作的地方
The latest commit of the current branch If you move (check out) a branch, the HEAD position will change 当前分支的最新提交如果移动(签出)分支,则HEAD位置将更改
The location of the remote repository where you are remotes / origin / HEAD-> origin / master // HEAD location 您所在的远程存储库的位置/原点/ HEAD-> origin / master // HEAD位置
They indicate at which commits the various branch pointers in your repository are currently. 它们指示存储库中当前处于哪个提交指针的提交分支。
HEAD -> master
means that this is the HEAD
, ie current working directory, which happens to belong to the master
branch. HEAD -> master
表示这是HEAD
,即当前工作目录,它恰好属于master
分支。
edeviserBranch
shows that your current local branch edeviserBranch
is also pointed at that same commit. edeviserBranch
显示您当前的本地分支edeviserBranch
也指向同一提交。
origin/master
at your previous commit means that the remote of your branch master
is still at that previous commit, ie your remote master is one commit behind your local repository. 先前提交时的
origin/master
意味着分支master
的远程仍处于该先前提交,即,远程主机是本地存储库后面的一个提交。
origin/HEAD
is the default branch/commit that will be checked out by someone cloning your repository anew (source) origin/HEAD
是默认的分支/提交,将由其他人重新克隆您的存储库(源)签出
Short answer 简短答案
It is a list of pointers which are pointing to the corresponding commit. 它是指向相应提交的指针的列表。 I recommend you read about
HEAD
and origin
. 我建议您阅读有关
HEAD
和origin
。
Commits and pointers 提交和指针
In git
, you have commits and pointers moving in between those commits. 在
git
,您有提交和在这些提交之间移动的指针。 A branch is just a pointer which points to a commit. 分支只是指向提交的指针。 Say you have a branch
mybranch
, then mybranch
is just a pointer. 假设您有一个分支
mybranch
,那么mybranch
只是一个指针。 If you commit on that branch, the pointer mybranch
just moves on to that commit. 如果您在该分支上提交,则指针
mybranch
会继续移至该提交。
The HEAD pointer HEAD指针
HEAD
: the HEAD
pointer points to the current commit your repo is on. HEAD
: HEAD
指针指向您的回购正在进行的当前提交。 In your case, it is pointing to commit 69b6309f09365c09a2fe10f09aee801d1fae29ee
, that is: your repo is now on commit 69b6309f09365c09a2fe10f09aee801d1fae29ee
. 在您的情况下,它指向commit
69b6309f09365c09a2fe10f09aee801d1fae29ee
,即:您的回购现在处于commit 69b6309f09365c09a2fe10f09aee801d1fae29ee
。 The content in parenthesis is a list of other pointers which point to the same commit as HEAD
, which, in your case are master
and edeviserBranch
. 括号中的内容是其他指针的列表,这些指针指向与
HEAD
相同的提交,在您的情况下为master
和edeviserBranch
。 From that information, you can see that master
and edeviserBranch
have not diverged yet. 从该信息中,您可以看到
master
和edeviserBranch
尚未分开。 You probably pushed the last commit with text added foo
onto master
and then created a new branch edeviserBranch
from master
. 您可能将带有
added foo
文本的最后一次提交推送到master
,然后从master
创建了一个新的分支edeviserBranch
。
The working area 工作区
origin
: the default name that git
gives to your remote repo. origin
: git
给您的远程仓库的默认名称。 With origin/<pointer>
, you can access branches in your working area. 使用
origin/<pointer>
,可以访问工作区中的分支。 The working area is a space between your local and remote repositories. 工作区是本地存储库和远程存储库之间的空间。
git fetch origin
downloads the data from your remote repo to the working area of your local repo. git fetch origin
将数据从您的远程仓库下载到本地仓库的工作区。 It doesn't merge any data, it just downloads it. 它不会合并任何数据,只会下载它。 An example to make the concept of working area clear:
阐明工作区概念的示例:
git fetch origin # update data from remote origin.
# For example, your remote branch edeviserBranch will be downloaded to your working area
# and can be accessed from origin/edeviserBranch.
git checkout master # go to your local master branch
git merge origin/edeviserBranch # merge branch edeviserBranch from your working area
# to your local master branch
The origin/HEAD pointer 原点/ HEAD指针
origin/HEAD
: a pointer in your working area which points to the default commit that will be checked out by someone cloning your repository. origin/HEAD
:工作区中的一个指针,它指向默认的提交,克隆人会将您的存储库检出该默认提交。
According to the output of git log
, pointer origin/master
and origin/HEAD
both point to commit 59a08270fb730db259a8d5819bb585a613024d97
. 根据
git log
的输出,指针origin/master
和origin/HEAD
都指向提交59a08270fb730db259a8d5819bb585a613024d97
。
If your working area is not synchronized with your remote repo, and you execute git fetch origin
(and doing so, you update your working area with your remote repo), those pointers will change. 如果您的工作区与远程仓库未同步,并且您执行
git fetch origin
(这样做,您将使用远程仓库更新工作区),则这些指针将更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.