59

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

torek
  • 448,244
  • 59
  • 642
  • 775
bao le
  • 927
  • 2
  • 7
  • 12
  • 1
    Did you install Git-LFS? (This is a separate program from Git, and apparently required by whatever software you're using.) – torek May 05 '21 at 07:06

10 Answers10

101

If you are on Mac, run:

brew install git-lfs
git lfs install
git lfs install --system
Michal Miky Jankovský
  • 3,089
  • 1
  • 35
  • 36
Lukasz Czerwinski
  • 13,499
  • 10
  • 55
  • 65
  • 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. – Zachary Drake Jan 04 '22 at 00:20
  • 1
    Thank you, helped! Had similar problem but with `git restore` – Vadixem Jan 28 '22 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 '22 at 08:25
  • Reference: https://formulae.brew.sh/formula/git-lfs – mrienstra Aug 28 '23 at 19:57
30

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
Ting Yi Shih
  • 792
  • 2
  • 9
  • 19
  • 1
    Thank you!! Only yours variant helped me!! – Sirelon Jan 30 '22 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. – James Selvakumar Mar 25 '22 at 09: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. – Ashish Sahu Apr 20 '22 at 19:07
  • If anyone is having this issue on Mac when trying to pull Unity packages this worked for me – thoxey Apr 26 '23 at 13:06
19

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
    
Codemaker2015
  • 12,190
  • 6
  • 97
  • 81
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

James Dube
  • 738
  • 7
  • 11
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
lnl
  • 358
  • 4
  • 11
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/

2

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
  • 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. – James Selvakumar Jul 28 '23 at 06:01
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

zzzzzsy
  • 31
  • 1
0

for RHEL/CentOS/RockyLinux/OracleLinux 9

dnf install git-lfs
Timmy Chiu
  • 549
  • 4
  • 13
0

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

trokiize
  • 69
  • 2
  • 7