Command to get latest Git commit hash from a branch

前端 未结 6 832
春和景丽
春和景丽 2021-01-30 04:39

How can I check with the command line the latest commit hash of a particular Git branch?

6条回答
  •  梦毁少年i
    2021-01-30 05:40

    Try using git log -n 1 after doing a git checkout branchname. This shows the commit hash, author, date and commit message for the latest commit.

    Perform a git pull origin/branchname first, to make sure your local repo matches upstream.

    If perhaps you would only like to see a list of the commits your local branch is behind on the remote branch do this:

    git fetch origin
    git cherry localbranch remotebranch
    

    This will list all the hashes of the commits that you have not yet merged into your local branch.

提交回复
热议问题