What does HEAD point to?
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?
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".
You could do:
git log master..origin/master
to list the commits that are "between" master
and origin/master
.
HEAD
points to the checked out commit.
Both the dot-dot syntax and HEAD are documented at gitrevisions(7).
This gives me a reasonably good way to look at differences while having commits from both branches visible
git-forest --date-order $(git merge-base master origin/master) master origin/master
(Alternatively, replace by gitk
or git log --oneline --graph
..)
You should use git fetch
not git pull
. git pull
would try to merge the branch. You are now in a conflict, use git merge --abort
to abort it.
精彩评论