Skip to content

Question: revert data (fetched and checked-out) to pointers after git lfs fetch #951

Open

Description

@dbiner

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

Activity

  1. technoweenie commented on Jan 27, 2016

    @technoweenie
    Contributor

    Hi @dbiner, could you explain why you want this? Just trying to understand the use case.

  2. dbiner commented on Jan 27, 2016

    @dbiner
    Author

    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.

  3. technoweenie commented on Feb 5, 2016

    @technoweenie
    Contributor

    Thanks for the use case. I've added it as a possible feature for Git LFS v1.2: #844.

  4. rBatt commented on Apr 4, 2016

    @rBatt

    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.

  5. technoweenie commented on Apr 4, 2016

    @technoweenie
    Contributor

    @rBatt The git lfs prune command 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).

    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.

  6. rBatt commented on Apr 4, 2016

    @rBatt

    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)

  7. rBatt commented on May 25, 2016

    @rBatt

    @technoweenie Is there another issue for this proposed feature, or has it been implemented?

  8. technoweenie commented on May 25, 2016

    @technoweenie
    Contributor

    Nope on both, unfortunately :(

  9. shoelzer commented on May 26, 2016

    @shoelzer

    Related: #1189

  10. Hendrikto commented on Feb 1, 2020

    @Hendrikto

    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.

  11. bk2204 commented on Feb 3, 2020

    @bk2204
    Member

    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.

  12. reopened this on Feb 3, 2020
  13. gongjun116403737 commented on Apr 3, 2021

    @gongjun116403737

    "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.

  14. gongjun116403737 commented on May 19, 2021

    @gongjun116403737

    @bk2204 , can you answer my question? thanks.
    After I execute git lfs pull --include "folder", is there any list which will add this "folder" ?

  15. bk2204 commented on May 19, 2021

    @bk2204
    Member

    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?

  16. vbalazs commented on Jun 2, 2023

    @vbalazs

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions