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 use brace expansion in gitrevisions <text>
  • Is there a 'git sed' or equivalent?
  • How do I exit my git commit message? I'm NOT in the VIM, I used the “ commit -m ” command
  • How to create alias for git bash to make fast cd through directories
  • Bash - get last dirname/filename in a file path argument
  • Escaping git bash after reflog, or commit, etc
  • branch1
    tag1
    tag2
    <commit-hash>
    tag3
    branch2
    master
    

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

  • Sharing Git Submodules
  • Using Git to merge all changes from a feature branch on develop to a release branch
  • What does the -u flag mean in git push -u origin master
  • Organize a large Project with multi private cocoapods
  • Use password instead of token with 2FA enabled on github
  • Git repository from github empty green folder
  • 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.