adamr
adamr

Reputation: 750

Simple versioning of each single file in git

Is there any way to have simple version number in format x.y per each single file in git repository? git-tag isn't solution in my case because I need to have on each commit incremented version of each single which is part of commit. Let's say I have following files in my repository:

FileA.txt 1.0
FileB.java 1.5
FileC.md 1.1

Each file has own version and now I'm pushing commit which changes FileA.txt and FileB.java, so I want to have state as below:

FileA.txt 1.1
FileB.java 1.6
FileC.md 1.1

Additionally I want to get file from git repository by providing the version of single file i.e. git show 1.0:FileA.txt or git checkout 1.0 FileA.txt

Upvotes: 1

Views: 1045

Answers (1)

Marina Liu
Marina Liu

Reputation: 38116

The direct answer is No.

Git for version control is based on the changes of each commit not each file. And It record each version by a calculated checksum (sha-1 value), so it can’t use the version number as x.y.

For other information:

  • You can use git blame filename to check what version of last commit for each line of the file.
  • You can use git log filename to check which commit(s) changed the file.
  • If the files are separately, you can manage them in different branches so that the files can be versioned separately.

Upvotes: 1

Related Questions