How do I get all the tags that are assigned to a file in git?

I need to to tell which revision/SHA1 of a file was associated with one or more tags. In CVS it is possible to get an output similar to to this:

File: abc.txt
Rev: 1.0
Tags: R1_0, R1_1

  • How does git abandon changes inside .git directory?
  • Git over ngrok tunnel forwarding
  • Can't add new file to repository in EGit
  • Using Git For Community-Oriented Website Content Revision System
  • Error with renamed repo in github, “remote: This repository moved. Please use the new location”
  • Git rebase develop before merging to develop?
  • Rev: 1.1
    Tags: R1_2

    How do you get a tag history for a file with git?

    Edit:
    I frequently use this function to tell which revision of a file is in production. I know which version (tag) of software is in production. Based upon this I would like to know which revision of a given file was tagged (and also which previous tags were associated to this file revision).

    In my example above:
    R1_1 will be in production. Querying abc.txt, I can tell that rev1.0 for abc.txt was used for both R1_0 and R1_1. (Thus unlikely that a new bug in R1_1 was caused by abc.txt because it still the same file as R1_0)

  • Commit changes to a submodule without having to commit the parent repo
  • Rename a file on git and keep history
  • Git Credential Management - allow to change passwords (Windows, TortoiseGit)
  • How to effectively use git repositories / submodules for a C++ product that has many dependencies?
  • Why do I have to resolve the same conflict over and over?
  • Checkout branch in Git Extensions creates branch with uppercase name
  • 3 Solutions collect form web for “How do I get all the tags that are assigned to a file in git?”

    I think you’re trying to be too specific in literally translating concepts from one revision control system to another. I’d ask, “how has abc.txt changed since R1_1?”

    git log R1_1.. -- abc.txt
    

    Now you know two things — that it’s changed, and how. Toss in a -p if you want to see the changes, too.

    Less Helpful, but What You Asked For:

    To do exactly what you’re asking for (which I think is less useful), and assuming you’re tagging properly:

    git describe `git log --pretty=format:%H -n 1 abc.txt`
    

    That shows you closest thing to a tag name for the last commit that changed the file.

    In git tags are always associated with state of whole project, not with the version of a single file. You can easily get however list of all files that changed between versions with “git diff --name-only R1_0 R1_1” (or more descriptive “git diff --stat --summary R1_0 R1_1“. You can get last commit that touched a file with “git log -1 <file>“.

    But if you want to find a bug, it is much better in my opinion to use git-bisect command to find which revision introduced bug. You would know not only which file has a bug, but which part of file introduced it (what change creared it).

    What are you trying to accomplish? The SHA1 identifies the state of the entire repo at that point in time.

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