You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question: revert data (fetched and checked-out) to pointers after git lfs fetch #951
Hi,
after a git clone the files are stored as text pointer, using then lfs fetch and lfs checkout the original files are then available.
The get the text pointers I found out that deleting the files and then revert it restored the text pointers but the fetched objects are still present (under .git/lfs). To revert the fetched data I parse to text pointers and delete then the according object under .git/lfs.
Is there a way to revert all or specific files to pointer again including the fetched files as prune does not delete the "recent" files?
Cheers
Hi @technoweenie! I have some simulations using big binaries. The simulations does a fetch and a checkout of the binaries needed, do some nice stuff with the data and uses then the fetched data to analyze the diff and in needs also commit/push the resulting data. The thing is that the local storage is limited and so it needs to revert/prune the used binaries back to text pointers. I hope it's clear enough.
Just wanted to chime in and say I think I could make use of this feature as well. I have a computer with limited harddrive space, and it would be nice to reset the history of large binaries being tracked in .git/lfs/ojbects ... I think that's what's being requested here. I.e., I am happy to have the current version of a large binary, but I can't afford the hard drive space to hold the history/versions of those files.
That said, I couldn't find where this possible feature was mentioned on #844. I saw that this issue was referenced, but didn't see it elsewhere, so I couldn't figure out if it had been implemented yet.
If I'm understanding correctly, @dbiner is asking for a command that replaces LFS tracked files in the working directory with the LFS pointer (basically, the inverse of git lfs checkout).
That said, I couldn't find where this possible feature was mentioned on #844.
Ugh, that's because I deleted it. We discussed trimming the list so we could get v1.2 out this week, potentially (see #844 (comment)). Course, I was an idiot and removed the old items from the issue body. In the future, I think we'll create those release issues as PRs on the changelog, so that all historical changes are preserved.
At any rate, the feature @dbiner is asking for won't make it into v1.2.
If you have questions about prune, would you mind opening a new issue for that? I'd prefer to keep this issue scoped to @dbiner's request only.
Any update on this? I would still appreciate this feature greatly. Should I open another issue? I have a slightly different use case, which I can explain if needed.
I'll reopen this to track it, but we don't currently have any update on adding it.
If (and only if) your working directory is clean, you can convert by running git read-tree HEAD && GIT_LFS_SKIP_SMUDGE=1 git checkout -f HEAD. If you run that in a dirty working tree, you'll blow away your changes, so don't do that.
Reacted by Maurizio Casciano, lollix89, trevor8961, Tamar Christina, altonchuzhan, Parsa Salavati, Sergey Pogorelov, Jan Blechta, tangb4c, Vincent Houlbrèque and 3 more
"Git prune " is working perfect.
But I have some suggestion. How about git prune support --include and --exclude?
because I only want to delete some binary files in specify folder and revert them back to pointer.
An other question, After I execute git lfs pull --include "folder", is there any list which will add this "folder".
because I found even I delete the binary file, git pull still download whole binary file rather than file pointer.
It's hard for me to say without knowing more about your scenario. Since this is a different question, can you please open an item in the Discussions area with your .gitattributes file; your .lfsconfig file, if any; and the exact commands you're running?
I ended up using is rm -f my/sub/dir/* && git checkout my/sub/dir 🤔 seems to do the trick for me. I guess some files might linger around and occasional pruning suggested above could help in that
Activity
technoweenie commentedon Jan 27, 2016
Hi @dbiner, could you explain why you want this? Just trying to understand the use case.
dbiner commentedon Jan 27, 2016
Hi @technoweenie! I have some simulations using big binaries. The simulations does a fetch and a checkout of the binaries needed, do some nice stuff with the data and uses then the fetched data to analyze the diff and in needs also commit/push the resulting data. The thing is that the local storage is limited and so it needs to revert/prune the used binaries back to text pointers. I hope it's clear enough.
technoweenie commentedon Feb 5, 2016
Thanks for the use case. I've added it as a possible feature for Git LFS v1.2: #844.
rBatt commentedon Apr 4, 2016
Just wanted to chime in and say I think I could make use of this feature as well. I have a computer with limited harddrive space, and it would be nice to reset the history of large binaries being tracked in
.git/lfs/ojbects... I think that's what's being requested here. I.e., I am happy to have the current version of a large binary, but I can't afford the hard drive space to hold the history/versions of those files.That said, I couldn't find where this possible feature was mentioned on #844. I saw that this issue was referenced, but didn't see it elsewhere, so I couldn't figure out if it had been implemented yet.
technoweenie commentedon Apr 4, 2016
@rBatt The
git lfs prunecommand will manage what files are kept in.git/lfs/objects.If I'm understanding correctly, @dbiner is asking for a command that replaces LFS tracked files in the working directory with the LFS pointer (basically, the inverse of
git lfs checkout).Ugh, that's because I deleted it. We discussed trimming the list so we could get v1.2 out this week, potentially (see #844 (comment)). Course, I was an idiot and removed the old items from the issue body. In the future, I think we'll create those release issues as PRs on the changelog, so that all historical changes are preserved.
At any rate, the feature @dbiner is asking for won't make it into v1.2.
If you have questions about prune, would you mind opening a new issue for that? I'd prefer to keep this issue scoped to @dbiner's request only.
rBatt commentedon Apr 4, 2016
Oh, I understand! The request replaces the "most current version of the file" with the pointer ... I'm just interested in the old versions.
Thanks for mentioning
git lfs prune... you just saved me 30+ GB of hard drive space (which on my laptop just doubled the free hard drive space :p)rBatt commentedon May 25, 2016
@technoweenie Is there another issue for this proposed feature, or has it been implemented?
technoweenie commentedon May 25, 2016
Nope on both, unfortunately :(
shoelzer commentedon May 26, 2016
Related: #1189
Hendrikto commentedon Feb 1, 2020
Any update on this? I would still appreciate this feature greatly. Should I open another issue? I have a slightly different use case, which I can explain if needed.
bk2204 commentedon Feb 3, 2020
I'll reopen this to track it, but we don't currently have any update on adding it.
If (and only if) your working directory is clean, you can convert by running
git read-tree HEAD && GIT_LFS_SKIP_SMUDGE=1 git checkout -f HEAD. If you run that in a dirty working tree, you'll blow away your changes, so don't do that.gongjun116403737 commentedon Apr 3, 2021
"Git prune " is working perfect.
But I have some suggestion. How about git prune support --include and --exclude?
because I only want to delete some binary files in specify folder and revert them back to pointer.
An other question, After I execute git lfs pull --include "folder", is there any list which will add this "folder".
because I found even I delete the binary file, git pull still download whole binary file rather than file pointer.
gongjun116403737 commentedon May 19, 2021
@bk2204 , can you answer my question? thanks.
After I execute git lfs pull --include "folder", is there any list which will add this "folder" ?
bk2204 commentedon May 19, 2021
It's hard for me to say without knowing more about your scenario. Since this is a different question, can you please open an item in the Discussions area with your
.gitattributesfile; your.lfsconfigfile, if any; and the exact commands you're running?vbalazs commentedon Jun 2, 2023
I ended up using is
rm -f my/sub/dir/* && git checkout my/sub/dir🤔 seems to do the trick for me. I guess some files might linger around and occasional pruning suggested above could help in that