Change file in Git from Git LFS to a normal Git file

787 Views Asked by At

I am trying to remove a .txt file that was being previously added as Git LFS.

In efforts to do so, I tried the following:

  • git lfs untrack "*.txt"
  • git add "*.txt"

And pushed changes. Still pushes files as LFS.

When I do git lfs uninstall, I get the below message:

Hook already exists: pre-push

    #!/bin/sh
    command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; }
    git lfs pre-push "$@"

    Hooks for this repository have been removed.
    Global Git LFS configuration has been removed.

And my .gitattributes file has the following:

    *.xlsx filter=lfs diff=lfs merge=lfs -text
    *.txt filter=lfs diff=lfs merge=lfs -text

I tried manually removing the contents of the .gitattributes file above and pushing again, but still no luck.

I even tried git lfs migrate export --include="*.txt" --everything but it would not allow me to push changes.

My current state: One .txt file is present as LFS file in GIT. I want this as a normal Git file.

Note: The file is a requirements.txt file, and is not a large file.

1

There are 1 best solutions below

0
On

There is probably a better way, but I just renamed the file twice. If you have multiple files you can move everything into a sub directory and then back. This fixed it for me after removing git lfs and the .gitattributes file.

Don't forget to commit after each rename/move.