开发者

What does HEAD point to?

开发者 https://www.devze.com 2023-01-27 17:02 出处:网络
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 differe

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
  1. 开发者_如何学运维Is there a better way?
  2. Also, what does HEAD point to, the checked-out commit?


  1. Is there a better way...

    1. to detect the line-by-line differences in the code?

      git diff origin/master..master

    2. to compare the commit histories?

      git log origin/master..master

  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消