How do I fix "git-lfs: command not found" on macOS?

53 Ansichten (letzte 30 Tage)
I want to use Git LFS to manage a Git repository which contains many large binary files.  I have downloaded Git LFS on my macOS machine, and it works just fine when running Git from a command line.  However, when I use Git within MATLAB, some operations fail with the error:
Error running filter git-lfs smudge -- <model name>.xlsx: /bin/sh: git-lfs: command not found
How do I resolve this error and using Git LFS from within MATLAB?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 8 Jun. 2023
When trying to run external executables, MATLAB will use the "PATH" environment variable (which is the Operating System's equivalent of MATLAB's internal 'path').  This error can occur if MATLAB is receiving a different value of PATH than command-line Git (one which does not contain the "git-lfs" executable).
Regardless of the values of the $PATH, the error can be resolved with the following steps:
  1. Find the location of the "git-lfs" executable, by running the command in a system terminal (i.e. not in MATLAB's Command Window):
    which git-lfs
    This will print the full path of the "git-lfs" executable (for example, /usr/local/bin/git-lfs).
  2. Open the file ~/.gitconfig, which is where Git stores its configuration.
  3. Replace any commands referring to "git-lfs" with its full path.  For example, if "git-lfs" is at /usr/local/bin/git-lfs, the following line:
    git config --global filter.lfs.clean "git-lfs clean -- %f"
    would be replaced with:\n
    git config --global filter.lfs.clean "/usr/local/bin/git-lfs clean -- %f"
This will make sure that, even when run from within MATLAB with a different $PATH value, Git will always load this exact file for "git-lfs".

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by