Reputation: 21386
I want to use LFS for an existing Git repository and track *.foo
files, converting the files in history too. I guess I can do this:
git lfs track "*.foo"
# changed `.gitattributes` and all `.foo` files
commit -a -m "Started tracking foo files."
git lfs migrate import --everything --include="*.foo"
Should I track the files before importing the repository, as I do above, or should I do that afterwards? Does it matter?
Upvotes: 3
Views: 1497
Reputation: 21386
In trying it both ways, it appears that importing a repository will turn on LFS tracking automatically, so there is no need to use git lfs track
separately.
git lfs migrate import --everything --include="*.foo"
In fact if you turn on tracking first, then you will have an extra commit where the file types are added to .gitattributes
. It turns out that git lfs migrate import
will actually add a .gitattributes
with the correct tracking information as the first commit in the history. If you don't have a .gitattributes
file, one will be added in the past.
Similarly if you don't have a .gitattributes
(let's say you converted the Git repository from a Subversion repository, for example), then if you first add your own .gitattributes
to the repository and commit it before doing git lfs track
, this will result in a version of .gitattributes
in the history that does not have LFS tracking turned on. If you do decide to add .gitattributes
manually, you should perform git lfs track…
before committing the file so that it will have tracking turned on in all the commits in which it appears.
So the best approach seems to be:
git lfs migrate…
before you do anything else..gitattributes
file that Git added with extra file types (if you didn't have a .gitattributes
file already).In summary, git lfs migrate import …
seems to include git lfs track …
functionality; there seems no need to call the latter separately, either before or after.
Upvotes: 4