How to have a file in git but not it's history?

Viewed 59

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?

1 Answers

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.

Related