How can I display commit's position in the history relative to tags (and branches)?

I’m looking for a way to get information about where a commit occurred relative to tags (and branches if possible). Is there some kind of command or group of commands (if necessary, I can use any bash commands as well) that I could give a commit hash and receive a list of all tags (and branches) in order with the commit in the correct position relative to the other tags? For example, if <commit-hash> occurred between tag2 and tag3, then the following command:

[command(s)] <commit-hash>

Would result in something like the following output:

  • How to display a specific user's commits in svn log?
  • User Input to Bash Alias?
  • Git completion and PS1 not working: “__git_ps1: command not found” on “sudo -s” or “sudo su” on Ubuntu 12.04
  • Run testng test in Git pre-commit hook
  • php shell exec acting different to running command directly
  • How can I get my git (msysgit on windows) post-commit script to invoke my python script as python rather than bash?
  • branch1

    I tried using git log to do this, but I’m really not sure where to start. Would this even be possible?

  • How to use --color-words with git add --patch?
  • Git log excluding branch
  • Git Merge Recursive Ours - Command Syntax Example
  • What is a git “Snapshot”?
  • avoid timestamps in git
  • AWS Elastic Beanstalk + Git Submodules
  • One Solution collect form web for “How can I display commit's position in the history relative to tags (and branches)?”

    git describe --tags $rev will give you a short description (see the man page for details) of the tag immediately before the revision.

    git describe --contains $rev will give you the first tag that contains the revision.

    git rev-list --branches --tags $rev might be a useful place to start also. You might be able to get something like what you want by using some of the “History Simplification” arguments to that function. I’d try --simplify-by-decoration first and then possibly --dense.

    To control the output of git rev-list you can use the --format argument. Use --format=%d to get the ref names (in an unfortunately annoying format however).

    Git Baby is a git and github fan, let's start git clone.