Search code examples
gitgit-lfsgit-for-windows

Which git-lfs does `git lfs` use?


I've just updated my installed Git LFS from https://github.com/git-lfs/git-lfs/releases to the latest version (2.3.0). However, when I run git lfs version I see:

$ git lfs version
git-lfs/2.2.1 (GitHub; windows amd64; go 1.8.3; git 621d1f82)

If I run git-lfs version I see the new version:

$ git-lfs version
git-lfs/2.3.0 (GitHub; windows amd64; go 1.8.3; git 4dd2bf73)

I'm not sure I understand where the git lfs command finds its git-lfs. I've hunted down a couple (or at least one) old git-lfs installation and deleted them, though git still seems to find an old one. And there's no other git-lfs in the path.

What would I need to do to tell git to use the newly installed version?

I'm running Windows 10 and using Cygwin. I get the same in PowerShell and cmd.

EDIT: I found this:

C:\Program Files\Git\mingw64\bin\git-lfs.exe

and this seems to be the old version:

$ /cygdrive/c/Program\ Files/Git/mingw64/bin/git-lfs.exe version
git-lfs/2.2.1 (GitHub; windows amd64; go 1.8.3; git 621d1f82)

Should I just delete this (and the other should be found via the PATH, or replace it with the new one? Or is there a more "official" way of doing this?


Solution

  • As a rule, when you run any arbitrary command that Git doesn't know as a built-in (or even one that Git does know as a built-in, really) such as:

    git asdf
    

    Git will search your $PATH for a program named git-asdf. Before doing this search, though, Git inserts its built-in git-core directory:

    $ git --exec-path
    /usr/lib/git-core
    

    (on an Ubuntu VM; on my Mac it's currently /usr/local/Cellar/git/2.15.1_1/libexec/git-core since that's the last update I installed there).

    Among other things, this means you can write your own Git commands and put them somewhere in your $PATH. But in this case it means that git lfs ... probably finds either $(git --exec-path)/git-lfs, or whatever your shell says if you run:

    $ which git-lfs
    

    assuming, of course, that you have a shell that supports this.

    Per your edit, I would imagine that git --exec-path produces C:\Program Files\Git\mingw64\bin.

    Should I just delete this (and the other should be found via the PATH, or replace it with the new one? Or is there a more "official" way of doing this?

    Deleting it will probably work. I foresee two main dangers of simply deleting the one in the git-core directory:

    • Sometimes Git and/or various things that work like plug-ins evolve at different paces. If there is a paired version of git-lfs that is known to work with that particular Git installation, some other git-lfs might not work because it might be out of sync. (So you might save it away in a third location, out of the way, rather than just removing it.)

    • Something might re-install the old one automatically, or de-install the new one. The former is just annoying while the latter would lead to failures (so having the old one saved away could be handy).