Skip to content

Latest commit

 

History

History
51 lines (35 loc) · 1.11 KB

index.md

File metadata and controls

51 lines (35 loc) · 1.11 KB

git branch-commit-last

Show a branch's last commit hash (or hashes)

Git alias:

branch-commit-last = "!f() { \
    branch="${1:-$(git current-branch)}"; \
    count="${2:-1}"; \
    git log --pretty=%H "$branch" | \
    head -"$count"; \
}; f"

Syntax:

git branch-commit-last [branch name [commit count]]

Options:

  • branch name: default is the current branch name.

  • commit count: default is 1

Example: show the current branch's last commit hash:

git branch-commit-last

Example: show the "foo" branch's last commit hash:

git branch-commit-last foo

Example: show the "foo" branch's last 3 commit hashes:

git branch-commit-last foo 3

Compare: