0

When I run npm install --save git+ssh://[email protected]:bmahsman/bubblegum.git, npm checks out the text files that git lfs puts in place of the actual assets. It appears npm isn't using my local user account's ~/.gitconfig, i.e. the lfs filters aren't being used and git-lfs is not being called.

I verified that git-lfs and git lfs work from both cmd and bash. I tried the above npm install command in both cmd and bash and I get the same result. I verified that git clone [email protected]:bmahsman/bubblegum.git from scratch produces the actual binary files instead of the text files.

My repo is located at https://github.com/bmahsman/bubblegum and I use Git LFS to manage binary art and sound assets, so it has a .gitattributes modified with git lfs track:

$ cat ./.gitattributes
*.png filter=lfs diff=lfs merge=lfs -text
*.ogv filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text

My local user account is configured for git this way:

$ cat ~/.gitconfig
[user]
    name = Brynn Mahsman
    email = [email protected]
[merge]
    ff = no
[credential]
    helper = cache
[alias]
    sc = git clone --recursive
    sp = push --recurse-submodules=on-demand
    su = submodule update --remote --merge
[push]
    default = simple
[filter "lfs"]
    clean = git-lfs clean %f
    smudge = git-lfs smudge %f
    required = true

I'm using Windows 7.

$ npm -v
2.14.7

$ git --version
git version 2.6.2.windows.1

edit: In case this is a bug, I've made an issue on GitHub.

2 Answers 2

1

(This is not an answer. It was supposed to be a comment on the question, but this account doesn't have the reputation to comment yet. Sorry about that.)

This looks like a bug in npm. I don't see anything you're doing wrong. Try here.

1
  • Thank you. I have made an issue on GitHub for both the git-lfs and npm projects.
    – May Oakes
    Dec 17, 2015 at 18:04
0

After poring over the output from git and npm with export GIT_TRACE=1 and npm config loglevel verbose, I believe I have figured out how to get this to work, at least with GitLab (I have since moved from GitHub to GitLab, which also supports Git LFS).

Step 1. Inside of your repository, run the following command (replace bubblegum with the name of your repo) and then commit the resulting .gitconfig and push:

$ git config -f .gitconfig lfs.url https://gitlab.com/brynn.mahsman/bubblegum.git/info/lfs

Step 2. In the directory in which you want to npm install your project, run for example:

$ npm install -S https://gitlab.com/brynn.mahsman/bubblegum.git


For this to work with GitHub, it would appear that the lfs.url to use is: https://api.github.com/lfs/<user or organization>/<repository name>, e.g.:

$ git config -f .gitconfig lfs.url https://api.github.com/lfs/brynn.mahsman/bubblegum


You may want to install a credential manager so that you don't have to enter your username and password every time git-lfs goes to retrieve a file. For Windows, I use Microsoft's credential manager.


The .gitconfig you commit to the repository allows the git commands used by npm install to know what lfs.url to use. I'm not sure if this solution only masks the fact that npm install can't figure out the lfs.url without you explicitly specifying it in .gitconfig. In other words, when I run the command git clone https://gitlab.com/brynn.mahsman/bubblegum.git, git somehow knows the lfs.url even if I don't have the .gitconfig in the repository.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .