I don't actually need the history of one particular file in my repository, I just need the latest version in git. Is there any way to do this?
Asked
Active
Viewed 70 times
-1
-
1What is the concern? Git is **version** control software. It tracks versions. – Daniel Mann Sep 06 '22 at 16:52
-
2There is no such thing as file history. There are only commits, and the commits *are* the history. The file is either in some commits, or it's not in the repository. (Or, in other words: no.) – torek Sep 06 '22 at 16:53
-
1Your main alternative here is to store the file somewhere outside Git. Then it's not in Git, and therefore not version-controlled by Git, and has no history. But it's not in the repository. – torek Sep 06 '22 at 16:55
-
@DanielMann my main problem is that when the file is quite big (example a mp4) it's make the size of the repository very big every time you change this file and that forever, even if you delete this file it's still in the history :( Option to store it somewhere else is not possible – zeus Sep 06 '22 at 17:00
-
5There are a few options for managing large binary files with Git that may work for you: https://stackoverflow.com/questions/540535/managing-large-binary-files-with-git – Basil Sep 06 '22 at 17:03
-
@torek But how to avoid a repository to grow like hell when you have some big files in it? if it's grow on the server side it's not a problem for me, the problem is that the repository grow on my local hard drive :( – zeus Sep 06 '22 at 17:03
-
Don't put such files into Git. See @Basil's link. – torek Sep 06 '22 at 19:05
1 Answers
0
Yes, you can tag just the one file. That's so very far from a standard workflow that none of Git's convenience commands will know what to do with it, but the Git core is about building the exact work flow you need.
git tag particular.file `git hash-object -w that/particular.file`
git push origin particular.file
Then on origin or any place that has fetched the particular.file
tag,
git show particular.file
You might need to force some updates when changing versions, and you might want to make it an annotated tag since those at least carry timestamps.

jthill
- 55,082
- 5
- 77
- 137
-
but is that user that simply do a git -clone url will immediatly see this file or they will be force to do a git show particular.file ? – zeus Sep 06 '22 at 17:06
-
1You specifically said you "just need the latest version in git". Let me know when you've got the goalposts where you really want them. – jthill Sep 06 '22 at 17:24