Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a Git log from HEAD?

Tags:

git

I am originally an SVN user.

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

How can I get the log from HEAD?

like image 504
Sungguk Lim Avatar asked Nov 05 '12 05:11

Sungguk Lim


People also ask

How do I view heads in git log?

In Git, a head is a ref that points to the tip (latest commit) of a branch. You can view your repository's heads in the path . git/refs/heads/ . In this path you will find one file for each branch, and the content in each file will be the commit ID of the tip (most recent commit) of that branch.

What does head -> Master mean in git log?

means that the symbolic reference HEAD currently points to the master branch; in other words, you are not in detached-HEAD state, and the current branch is master .

What does head -> branch mean?

In Git, this is a pointer to the local branch you're currently on. In this case, you're still on master. HEAD is pointing to a specific branch but the git log command is also showing you where the remote branch is in relation to your local branch.

How do I view files in git log?

To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.


1 Answers

To get log from server-side HEAD, you need to fetch changes from the server first. Unlike pull, fetch is not going to affect your working tree. So, it's safe.

  1. git fetch origin

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

  2. git log origin\master

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

Other useful git log options:

i) git log HEAD..origin\master

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

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

Show the commits as a patch.

iii) git log -5

Shows the latest 5 commits.

like image 96
Karthik Bose Avatar answered Sep 28 '22 10:09

Karthik Bose