Command to get latest Git commit hash from a branch

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

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

6条回答
  •  春和景丽
    2021-01-30 05:38

    In a comment you wrote

    i want to show that there is a difference in local and github repo

    As already mentioned in another answer, you should do a git fetch origin first. Then, if the remote is ahead of your current branch, you can list all commits between your local branch and the remote with

    git log master..origin/master --stat
    

    If your local branch is ahead:

    git log origin/master..master --stat
    

    --stat shows a list of changed files as well.

    If you want to explicitly list the additions and deletions, use git diff:

    git diff master origin/master
    

提交回复
热议问题