To turn any extended object reference into a hash, use git-rev-parse
:
git rev-parse HEAD
or
git rev-parse --verify HEAD
To retrieve the short hash:
git rev-parse --short HEAD
To turn references (e.g. branches and tags) into hashes, use git show-ref
and git for-each-ref
.
Related Contents:
- How does Git compute file hashes?
- Telling if a Git commit is a Merge/Revert commit
- How does Git create unique commit hashes, mainly the first few characters?
- How do I delete a Git branch locally and remotely?
- How do I discard unstaged changes in Git?
- Link to the issue number on GitHub within a commit message
- Merge development branch with master
- How to link a folder with an existing Heroku app
- Are Git forks actually Git clones?
- How can I fix the Git error “object file … is empty”?
- How would Git handle a SHA-1 collision on a blob?
- How to un-submodule a Git submodule?
- How can I recover a lost commit in Git?
- What to do with branch after merge
- Start ssh-agent on login [closed]
- What’s the purpose of git-mv?
- Merge two Git repositories without breaking file history
- update package.json version automatically
- fatal: Not a valid object name: ‘master’
- Get a list of all git commits, including the ‘lost’ ones
- What is `git diff –patience` for?
- Git says remote ref does not exist when I delete remote branch
- What does the git index contain EXACTLY?
- Configuring diff tool with .gitconfig
- Adding git branch on the Bash command prompt
- How do I fetch a branch on someone else’s fork on GitHub? [duplicate]
- git add * (asterisk) vs git add . (period)
- How to show full-file git blame in vs code
- How to abort a git rebase from inside vim during interactive editing
- Remote branch on Visual Studio online doesn’t appear on Visual Studio 2015 Team Explorer
- git – how to get default branch?
- Git stash twice
- Cannot checkout, file is unmerged
- Rebasing and what does one mean by rebasing pushed commits
- Git pulling a branch from another repository?
- How to use Git credential store on WSL (Ubuntu on Windows)?
- Link latest file on Bitbucket Git repository
- Git submodules not updating in Jenkins build
- What does “fatal: bad revision” mean?
- git is very very slow when tracking large binary files
- Azure DevOps – compare two commits right in the web UI?
- How do I move my local Git repository to a remote Git repository
- How to commit only modified (and not new or deleted) files?
- Mirroring from GitLab to GitHub
- When to use the ‘–no-ff’ merge option in Git
- What is the difference between Git Bash and the GitHub for Windows shell?
- git push error: src refspec main does not match any on linux
- How do I configure Git to automatically pull from current branch when using “git pull”?
- How can I choose to overwrite remote repository with local commits?
- What does GIT PUSH do exactly?