Command to get latest Git commit hash from a branch

前端 未结 6 822
春和景丽
春和景丽 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:43

    Note that when using "git log -n 1 [branch_name]" option. -n returns only one line of log but order in which this is returned is not guaranteed. Following is extract from git-log man page

    .....
    .....
    Commit Limiting
    
    Besides specifying a range of commits that should be listed using the special notations explained in the     description, additional commit limiting may be applied.
    
    Using more options generally further limits the output (e.g. --since= limits to commits newer than , and using it with --grep= further limits to commits whose log message has a line that matches ), unless otherwise noted.
    
    Note that these are applied before commit ordering and formatting options, such as --reverse.
    
    -
    -n 
    .....
    .....
    

提交回复
热议问题