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
?
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.
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 .
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.
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.
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.
git fetch origin
Here origin
is your remote repo. This command fetches the latest data from the remote repo.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With