New Solution
The original solution is from 2016. Tech progresses...
Seems the best solution now is
git lfs migrate
Thanks to @iff_or for alerting me to this (see comments).
Outdated Solution, don't use
I then discovered a few fixes, some of which seem to be bugs, some of which simply were not obvious to me.
It seems that in order to use
lfswith an existing repository, a hack or third party tool such as BFG's converter is needed.- I did not want to go that route, so I simply initialized a new repository locally, then did the challenge of hooking it back up to the real repo.
- I created a new directory, then
git init, etc.- In my case, the remote repository was GitHub. So I did all those proper hookups like
git remote add origin [email protected]:<my_id>/<my_repo>.git
- In my case, the remote repository was GitHub. So I did all those proper hookups like
Also, while Git's Training Video claims that you can simply specify a folder, such as
"my_folder/", I could not get this to work. Therefore, I just cleverly used filename extensions to manage things.- For example,
git lfs track "my_folder/"would not work for me, butgit lfs track "*.zip"did work.
- For example,
I had no luck getting LFS files to be identified correctly unless I had first updated the
.gitattributesfile, and committed and pushed that new file to the remote server.git lfs track "*.zip"git add .gitattributesgit commit -m "Updated the attributes"git pushgit add my_large_file.zipgit lfs ls-files- And here I would ensure that I saw
my_large_file.zipbeing tracked.
- And here I would ensure that I saw
git commit -m "Now I am adding the large file"git push
It's possible that some of the things work, and I was simply doing them wrong. However, following the witchcraft described above finally got LFS to work, so I thought I'd pass on these details for others, in case someone else had the same problem.
Answer from Mike Williamson on Stack Overflowgithub - Git LFS refused to track my large files properly, until I did the following - Stack Overflow
Git lfs with files in repo that are already committed
Unable to track a large file (103mb) without extension using Git LFS.
git lfs - How to add a single file to GIT LFS? - Stack Overflow
Videos
New Solution
The original solution is from 2016. Tech progresses...
Seems the best solution now is
git lfs migrate
Thanks to @iff_or for alerting me to this (see comments).
Outdated Solution, don't use
I then discovered a few fixes, some of which seem to be bugs, some of which simply were not obvious to me.
It seems that in order to use
lfswith an existing repository, a hack or third party tool such as BFG's converter is needed.- I did not want to go that route, so I simply initialized a new repository locally, then did the challenge of hooking it back up to the real repo.
- I created a new directory, then
git init, etc.- In my case, the remote repository was GitHub. So I did all those proper hookups like
git remote add origin [email protected]:<my_id>/<my_repo>.git
- In my case, the remote repository was GitHub. So I did all those proper hookups like
Also, while Git's Training Video claims that you can simply specify a folder, such as
"my_folder/", I could not get this to work. Therefore, I just cleverly used filename extensions to manage things.- For example,
git lfs track "my_folder/"would not work for me, butgit lfs track "*.zip"did work.
- For example,
I had no luck getting LFS files to be identified correctly unless I had first updated the
.gitattributesfile, and committed and pushed that new file to the remote server.git lfs track "*.zip"git add .gitattributesgit commit -m "Updated the attributes"git pushgit add my_large_file.zipgit lfs ls-files- And here I would ensure that I saw
my_large_file.zipbeing tracked.
- And here I would ensure that I saw
git commit -m "Now I am adding the large file"git push
It's possible that some of the things work, and I was simply doing them wrong. However, following the witchcraft described above finally got LFS to work, so I thought I'd pass on these details for others, in case someone else had the same problem.
To put files on an existing repo on lfs you can also do:
git lfs migrate import --include="*.mp3,*.pth"
(Replace .mp3 and .pth with the file extension you wish to put on lfs)
I'm trying to get Git LFS to track a large file. Since the large file has no extension, I tried to track the folder. But somehow I'm unable to track the folder where this file is in. I fucked everything up before, so this is what I've got going on now.
-
I temporarily deleted the 103 MB file from my project.
-
I deleted all the .gitattributes track commands from the file.
-
My local and remote repositories are equal right now, branch is up to date.
Everytime I add the file back to the folder, track the folder and try to push I get this same error: https://i.imgur.com/Uo41z7Z.png
MyTargetSDK.framework is the folder the big file is in. I tried these lines to track the folder:
git lfs track 'Horror Game/Assets/Plugins/iOS/Yodo1Ads/thirdsdk/Yodo1MyTarget/MyTargetSDK.framework'
git lfs track 'D:\Unity\EvilKid\Horror Game\Assets\Plugins\iOS\Yodo1Ads\thirdsdk\Yodo1MyTarget\MyTargetSDK.framework'
git lfs track 'D:/Unity/EvilKid/Horror Game/Assets/Plugins/iOS/Yodo1Ads/thirdsdk/Yodo1MyTarget/MyTargetSDK.framework'
git lfs track 'Yodo1Ads/**'
I'm hoping someone could tell me how I can succesfully track the folder where this huge file is in and push everything to my remote repos.
Fixed the problem thanks to u/pi3832v2 I used this line to track my file: git lfs track --filename "MyTargetSDK"
Use:
git lfs track --filename [file path]
Source: git lfs track --help
--filename
Treat the arguments as literal filenames, not as patterns. Any special glob characters in the filename will be escaped when writing the .gitattributes file.
This option has been available since v2.9.0 of the LFS extension (pull request). You can check your local version: git lfs version.
Include the path to the file, instead of just the filename.