9

I installed git-lfs using homebrew, and it works fine from the command line. I can still add text files in Xcode as well, but whenever I try in Xcode to add a file which should be tracked by git-lfs, there is no effect (the file stays "?" in Xcode's file list, and the command line confirms that the file was not, in fact, added). After some research, I tried adding ~/Library/LaunchAgents/my.startup.plist to setenv PATH /usr/local/bin but it had no effect.

How can I get Xcode to play nice with git-lfs?

2 Answers 2

13

We have a similar issue, our CI uses Xcode's git and not the homebrew one. So we needed to get git-lfs working in Xcode. This proved pretty simple: copying the git-lfs core file from the homebrew version into Xcode (you need to do this again every time you upgrade Xcode):

sudo ln -s `which git-lfs` /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-lfs 

Edited to highlight great improvement by @blackjack75.

Sign up to request clarification or add additional context in comments.

3 Comments

Same in an one-liner finding the current git sudo ln -s `which git-lfs` /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-lfs
Or even better when you have multiple Xcode versions on the machine and it is not named Xcode.app sudo ln -s `which git-lfs` `xcode-select -p`/usr/libexec/git-core/git-lfs
At first this does not appear to work in MacOS 14.6 ("Operation not permitted"). But after you try this ln command, you can then go into Settings / Privacy & Security / App Management then tick on "Allow the applications below to update or delete other applications" and then it works
5

There seem to be a problem with using git-lfs with Xcode. See this article: http://gopalkri.com/2016/05/17/git-lfs-xcode-asset-catalogs/

Might be better off to stick with Git to commit your changes instead of doing it via Xcode.

3 Comments

3 years later and it still seems to be an issue.. Any updates?
Feels like still a default issue here at... 7 years later?
Ya Xcode does have it's own git (in /Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/), but for some reason it can't seem to find the homebrew installed git-lfs when running the git from that folder. It does not come with a git-lfs in that folder either. The other answer makes a symbolic link inside that folder so Xcode's git can find git-lfs, (but there's a little catch, see my comment on that other answer above)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.