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

I am facing this issue on mac os. iit lfs command is working fine on terminal. But when I am running this command from some script it is trying to find the lfs command into the git this is what I understand so far.

Please help me out in fixing this.

Noman Maqsood
  • 419
  • 1
  • 4
  • 6
  • You've installed a custom version of Git on your system. You also have a non-custom version of Git—a standard install—on your system. When you run commands from a Terminal window, which Git do you use? When you run them from your IDE or whatever this other program may be, which Git do you use? (These are exercises for you to solve, which should, ideally, lead you to whatever the actual solution may be. Since I do not have your scripts, I cannot guess how to make them use the desired Git version.) – torek Nov 11 '19 at 16:46
  • It is the standard version of Git that is shipped with macos – Noman Maqsood Nov 12 '19 at 06:44
  • You said "it is", as if there is only *one* version of Git on your system, but this is not the case. There are *two* versions of Git on your system. – torek Nov 12 '19 at 06:58
  • Can you modify the PATH from your scripts so that it points to the same git binary as the one you run from your terminal? Maybe check the PATH from your script and compare it with the PATH from your terminal. Then adjust the PATH from the script to match the one from the terminal. – Haibrayn González Oct 02 '20 at 16:37

2 Answers2

43
  • Homebrew user run
brew install git-lfs
  • MacPorts user run
port install git-lfs

Verify that the installation was successful:

$ git lfs install
> Git LFS initialized.

For more details refer to this doc: https://help.github.com/en/github/managing-large-files/installing-git-large-file-storage

Max Peng
  • 2,879
  • 1
  • 26
  • 43
  • 1
    please read the description again, I already mentioned that git lfs is installed and it is accessible by terminal but not by some programming script And FYI it is installed using hombrew – Noman Maqsood Nov 11 '19 at 08:32
  • it is Eagle CAD script, you might not able to understand it – Noman Maqsood Nov 11 '19 at 11:43
  • Worth mentioning that, in addition to Homebrew or MacPorts, you can install directly, as [welch's answer](https://stackoverflow.com/a/65800906/1028230) suggests. – ruffin Mar 09 '22 at 01:28
  • This works! I installed with `brew install git-lfs`, and pushed successfully with LFS, but still couldn't run `git lfs checkout` before running `git lfs install`. – kwkt Aug 23 '23 at 18:55
6

When using the apple xcode-provided git, in /usr/bin/git, and after installing the git-lfs download from https://git-lfs.github.com/, you'll find git-lfs was placed in /usr/local/bin/git-lfs. You may need to add /usr/local/bin to your PATH so that git can find this. (I've not looked to see what brew and macports do)

welch
  • 936
  • 8
  • 12
  • for me, `/usr/local/bin` is already in my path. This only happens when trying to use git-lfs from a third-party application (matlab). I was wondering if putting a symlink to `/usr/local/bin/git-lfs` in `/usr/bin/git-lfs` would work, or if there's some way to force matlab to search in `/usr/local/bin` – Brian D Aug 18 '21 at 12:49
  • Appending `/usr/local/bin` to the PATH from within the application was the key for me. `[~, result] = system('echo -n $PATH'); result = [result ':/usr/local/bin']; setenv('PATH', result);` (in matlab) – Brian D Aug 18 '21 at 17:28
  • make sure that mac has properly set the path, even after exporting and re-sourcing the rc file before giving up on this sltn – Chris Aug 27 '21 at 14:47