-1

Git allows you to tag commits. What I am looking for however is to tag individual files. I would like the tag to remain with the file even when the file is part of multiple commits. In other words, the tag is always associated with the file until I either remove it or rename it. Is this possible with Git?

Johann
  • 27,536
  • 39
  • 165
  • 279
  • 2
    Why do you need it? – choroba Jun 22 '16 at 14:16
  • 2
    Possible duplicate of [How to Tag a single file in GIT](http://stackoverflow.com/questions/5959622/how-to-tag-a-single-file-in-git) – Don Branson Jun 22 '16 at 14:32
  • @choroba Need to group files that serve a combined functionality. By applying a tag, I could then just list all the files that have a specific tag. That lets me open up the files in my IDE. Currently, my IDE (Intellij) doesn't let me group a collection of files that serve a common functionality and when I need to work on that functionality, it would be nice to know what files belong to it. The tagging would help here. – Johann Jun 22 '16 at 14:39
  • That really has nothing to do with git. You may need to look at categorization specific to the technology you're using. Java, for example, allows for the grouping of source files into packages. Other technologies will typically have something that addresses this. – Don Branson Jun 22 '16 at 15:23

2 Answers2

-1

A tag can point to a git object. There are four kinds of git objects. They are commits, trees, blobs and tags. And a tag never moves. If you want a tag to be associated with a file, you could make a tag which points to a blob. A blob is a snapshot of a file. If the file is changed, Git creates another blob. One tag can point to only one blob and cannot point to the new blob like a branch moves from one commit to another commit.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53
-1

Maybe another way to approach this is to store the file under a different git tree, so maybe try submodules.

David Neiss
  • 8,161
  • 2
  • 20
  • 21