HEAD 指向什么?
我想将本地 master
分支与远程 origin/master
分支进行比较。我知道如何做 git pull --rebase;从我的本地 master
分支中执行 git diff origin/master 来检测代码中的逐行差异。但是,我想比较提交历史记录,即并排显示 git log 和 git log origin/master 。我尝试了 git show-branch -a ,但得到:
* [master] change content background-color to blue
! [origin/HEAD] add favicon
! [origin/master] add favicon
---
* [master] change content background-color to blue
*++ [origin/HEAD] add favicon
- 有更好的方法吗?
- 另外,
HEAD
指向什么,签出的提交?
I want to compare my local master
branch with the remote origin/master
branch. I know how to do git pull --rebase; git diff origin/master
from my local master
branch to detect the line-by-line differences in the code. But, I want to compare the commit histories, i.e., show git log
and git log origin/master
side-by-side. I tried git show-branch -a
but got:
* [master] change content background-color to blue
! [origin/HEAD] add favicon
! [origin/master] add favicon
---
* [master] change content background-color to blue
*++ [origin/HEAD] add favicon
- Is there a better way?
- Also, what does
HEAD
point to, the checked-out commit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
有没有更好的方法...
检测代码中的逐行差异?
git diff origin/master..master
比较提交历史记录?
git log origin/master..master
另外,HEAD 指向什么,签出的提交?
HEAD 指向当前“分支”的“尖端”。
Is there a better way...
to detect the line-by-line differences in the code?
git diff origin/master..master
to compare the commit histories?
git log origin/master..master
Also, what does HEAD point to, the checked-out commit?
HEAD points to the "tip" of the current "branch".
您可以这样做:
列出
master
和origin/master
“之间”的提交。HEAD
指向已签出的提交。点点语法和 HEAD 均记录在 gitrevisions(7) 。
You could do:
to list the commits that are "between"
master
andorigin/master
.HEAD
points to the checked out commit.Both the dot-dot syntax and HEAD are documented at gitrevisions(7).
这为我提供了一种相当好的方法来查看差异,同时使两个分支的提交可见
(或者,替换为 gitk 或 git log --oneline --graph ..)
This gives me a reasonably good way to look at differences while having commits from both branches visible
(Alternatively, replace by
gitk
orgit log --oneline --graph
..)您应该使用 git fetch 而不是 git pull 。 git pull 会尝试合并分支。您现在处于冲突中,请使用 git merge --abort 来中止它。
You should use
git fetch
notgit pull
.git pull
would try to merge the branch. You are now in a conflict, usegit merge --abort
to abort it.