63

I'm trying to clone a project from git by this:

git clone link

And got this message

remote: Enumerating objects: 24533, done.
remote: Counting objects: 100% (24533/24533), done.
remote: Compressing objects: 100% (5045/5045), done.
remote: Total 24533 (delta 15448), reused 24389 (delta 15306), pack-reused 0
Receiving objects: 100% (24533/24533), 75.12 MiB | 10.96 MiB/s, done.
Resolving deltas: 100% (15448/15448), done.
git-lfs filter-process: git-lfs: command not found
fatal: the remote end hung up unexpectedly
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

I've been searching around and tried:

git config --system core.longpaths true

but it doensn't work and my disk is plenty free

1
  • 1
    Did you install Git-LFS? (This is a separate program from Git, and apparently required by whatever software you're using.)
    – torek
    May 5, 2021 at 7:06

10 Answers 10

108

If you are on Mac, run:

brew install git-lfs
git lfs install
git lfs install --system
4
  • Thanks, this seemed to work for me. I didn't know this was a separate program. I think everyone who wrote the "docs" has it installed, so they don't remember to ask new folks to install it. Jan 4, 2022 at 0:20
  • 1
    Thank you, helped! Had similar problem but with git restore
    – Vadixem
    Jan 28, 2022 at 16:09
  • On Windows, I just re-installed git via the installer and chose Git LFS (Large File Support) option on "Select Components" step and it worked
    – traxium
    Apr 12, 2022 at 8:25
  • Reference: formulae.brew.sh/formula/git-lfs
    – mrienstra
    Aug 28 at 19:57
31

TL;DR

Perhaps git didn't get linked to git-lfs on the machine. Try linking it:

ln -s "$(which git-lfs)" "$(git --exec-path)/git-lfs"

Explanation

Although it said something missing, git-lfs could actually be installed on the machine but git just didn't find it in its search path. Therefore, we create a symbolic file in its search path:

$(git --exec-path)/git-lfs

linking to the typically installed one on the machine:

which git-lfs
4
  • 1
    Thank you!! Only yours variant helped me!!
    – Sirelon
    Jan 30, 2022 at 19:10
  • Elegant solution. I faced this problem as I installed git-lfs using homebrew. So, the git that's shipped with Xcode was not aware of that. Linking them solved the issue. Though, I'm not sure whether the problem will reappear after Xcode updates. Mar 25, 2022 at 9:17
  • This is very import on, everyone already know how to install git-lfs but don't know linking is also required for other program to work such as android studio version control. Apr 20, 2022 at 19:07
  • If anyone is having this issue on Mac when trying to pull Unity packages this worked for me
    – thoxey
    Apr 26 at 13:06
20

You might try to push a repository that contains files of huge size. So, We have to install git-lfs in that case.

For Windows:

  • Download git-lfs from the official site (download) and install it in your machine.

  • Then set up Git LFS for your user account by running the following command in your terminal:

    git lfs install
    

For Mac:

  • Run the following commands in your terminal.

    brew install git-lfs
    git lfs install
    

For Ubuntu:

  • Run the following commands in your terminal.

    sudo apt install git-lfs
    git lfs install
    
1
  • Don't forget sudo apt-get update :)
    – eliteproxy
    May 24 at 21:01
5

Encountered the same problem, the answer by Teodoriko did not work for me got the result:

git: 'lfs' is not a git command. See 'git --help'.

What worked for me was to install the dependency with:

sudo apt install git-lfs

My git version 2.27.0

5

If you intentionally removed git-lfs, and don't want to install it back as other answers suggest, your way out is:

git config --global --remove-section filter.lfs
4

I have stumbled upon the very same error on a Mac OS. The cause is a conflict between the version of Git included in Xcode Command Line Tools and the Git LFS version installed via HomeBrew.

Basically, as hinted by the top voted answer, the Git binary executable (git) expects the binary executable of the Git LFS extension to be located inside the directory of its execution path.

Even though the Git binary executable installed by Xcode Command Line Tools is physically located in /usr/bin/git

~ which git
/usr/bin/git

its execution path is another directory

~ git --exec-path
/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core

Therefore git is not able to find git-lfs binary inside /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core, as the latter is located in /opt/opt/homebrew/bin/git-lfs

~ which git-lfs
/opt/homebrew/bin/git-lfs

That explains the need of the symlink proposed in the top answer:

sudo ln -s "$(which git-lfs)" "$(git --exec-path)/git-lfs"

Unfortunately, in recent versions of Mac OS that command does not work:

~ sudo ln -s "$(which git-lfs)" "$(git --exec-path)/git-lfs"
ln: /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-lfs: Operation not permitted

That error is due to the System Integrity Protection, aka "SIP", a feature enabled in recent versions of Mac OS. It basically makes parts of the file system read-only to everybody, including root: even prepending sudo, as shown above, is ineffective.

Said that, the only solution that worked for me was installing also Git via brew

~ brew install git

ensuring that the HomeBrew binaries have precedence over system ones:

~ echo $PATH
opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/Library/Apple/usr/bin
3
  • Very nice explanation. I faced the same problem too. I tried your solution, but Xcode still reports that it couldn't find git-lfs when I try to commit. Jul 28 at 6:01
  • Actually git-lfs tool is not shipped with Xcode, but it needs to be installed independently. And that is the cause of this issue in the first place. Sep 27 at 15:52
  • This should be the correct answer, especially for new Macs with System Integrity Protection. Sep 28 at 13:41
2

This is a simple one. Check the documentation to the installation types based on your OS. For linux, just follow these commands:

  1. Download and install the Git command line extension. Once downloaded and installed, set up Git LFS for your user account by running:

    git lfs install
    

You only need to run this once per user account.

  1. In each Git repository where you want to use Git LFS, select the file types you'd like Git LFS to manage (or directly edit your .gitattributes). You can configure additional file extensions at anytime.

    git lfs track "*.psd"
    

Now make sure .gitattributes is tracked:

  git add .gitattributes

Note that defining the file types Git LFS should track will not, by itself, convert any pre-existing files to Git LFS, such as files on other branches or in your prior commit history. To do that, use the git lfs migrate[1] command, which has a range of options designed to suit various potential use cases.

  1. There is no step three. Just commit and push to GitHub as you normally would; for instance, if your current branch is named main:

    git add file.psd
    
    git commit -m "Add design file"
    
    git push origin main
    

References: https://git-lfs.github.com/

1

My issue is caused by too many projects in the intelliJ IDEA project group. so the git-lfs crashed when indexing all the projects I think. I was able to fix it by regrouping my projects (splitting them into more groups). hope it helps someone

0

for RHEL/CentOS/RockyLinux/OracleLinux 9

dnf install git-lfs
0

For me on Mac M1 the following command has worked sudo cp -n $(which git-lfs) /usr/local/bin/

1
  • I hope you understand that every new version you will have to do this? :) May 16 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.