Xcode may not be executing Git hooks

I am trying out the use of Git LFS with a repository for an iOS app. Everything is fine except when I try to use Git through Xcode or with an Xcode Bot.


With the Xcdoe 9.2 IDE, I do the following:


  1. Switch to the Source Control navigator (⌘2)
  2. Right-click on the branch with the large file references
  3. Click Checkout...

After the checkout process completes, the large files are not applied. Instead, I get the referencing files, such as the following:


version https://git-lfs.github.com/spec/v1
oid sha256:d2c5ffeaaf53d92e57dacca17e83259bea0d53c841520f3138cc79415a3d89c8
size 3364784


This is not a path problem as far as I can tell. I've tried updating the PATH environment variable for launchd (via a plist in ~/Library/LaunchAgents and rebooting). That correclty extends the search path so that git-lfs should be found (verified with launctl getenv PATH). I also tried putting the git-lfs executable in /Applications/Xcode.app/Contents/Developer/usr/bin, but the result is the same.


It really seems like the way that Xcode is using Git to check out the branch is not executing the post-checkout hook. The hooks are all what seem to be the standard for Git LFS. For example, here is post-checout:


#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting .git/hooks/post-checkout.\n"; exit 2; }
git lfs post-checkout "$@"


Is there anything about Xcode's use of Git that would skip the hooks? If so, is there a way to make those hooks get executed?

Post not yet marked as solved Up vote post of pfh Down vote post of pfh
1.9k views
  • I'm also seeing this same behaviour, with Xcode 12.5.1 on Big Sur (I am also trying to use Git LFS).

    I've added code to my hooks to just echo some text to a file, to see if they are firing. Most don't fire when using the Xcode Git commands through the GUI, but do if run from the Terminal (including using xcrun git <command>).

    It appears that the 'pre-commit' hook runs, but the others I have tried don't.

    It seems crazy to me that this important piece of functionality of the only supported version control system doesn't work with Xcode. Surely this can't be the case?

Add a Comment