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

56 次查看(过去 30 天)
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?

采纳的回答

MathWorks Support Team
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".

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by