How can I get the Git log from HEAD?

I am originally an SVN user.

In Git, git log displays only the log from the current commit.

How can I get a log from HEAD ?

+4
source share
3 answers

To get the log on the server side of HEAD, you must first get the changes from the server. Unlike pull , fetch will not affect your working tree. Therefore, it is safe.

  • git fetch origin

    Here origin is your remote repo. This command retrieves the latest data from a remote repo.

  • git log origin\master

    Here, origin\master means the master branch in the remote origin repo. This command shows the log from origin\master .

Other useful git log options:

i) git log HEAD..origin\master

Show commits that are in the "origin / master" branch but not yet in the "HEAD" branch.

ii) git log -p HEAD..origin\master

Show commit as a patch.

iii) git log -5

Shows the last 5 commits.

+6
source

Since you only need one revision, run

git log -n 1

or

git log -n 1 HEAD

+2
source
 git log 

means

 git log HEAD 

HEAD implied in other commands if there is no link. HEAD means “current commit” - no matter which branch you are in, or even if you are not in any industry. If you want to see all the links, you can do

 git log --all --decorate 

all will show you all the links (tips of any branches) and their ancestors. decorate will note that the result captures any links that point to them. You can set this default behavior for the current user with git config --global log.decorate true .

In the above configuration, I usually do git log --all --graph . graph links each commit to ASCII art lines to see their relationship. If I want to see more information at the same time, --oneline also useful.

0
source

Source: https://habr.com/ru/post/1444038/


All Articles