obsidian-git
obsidian-git copied to clipboard
Large File Storage
@denolehov, thank you for this plugin!
I tried to use git-lfs feature for my images sub-folder and here is error in my console:
This 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/pre-push.
Basically, hook content looks like this:
#!/bin/sh
command -v git-lfs && git lfs pre-push "$@"
I wonder if this can be fixed just by passing parent PATH via this option.
More context:
Obsidian: 0.9.14
OS: macOS Big Sur
To reproduce, I guess it would be enough to follow this setup. Also, maybe I'll be able to figure out obsidian plugin development setup and debug it on my own.
UPD. As I can see, obsidian process doesn't contain /usr/local/bin directory in its PATH, i.e. it uses system-wide git command instead of homebrew-installed one.
Hey, I will look into this closer to next weekend. Sorry for the late reply.
Similar issue to #21, but in the case of git-lfs, I don't think there is a git-config option to set the path to git-lfs. So perhaps the best would be to introduce two new plugin settings: "Path to git" and "Path to git-lfs", that can be used to override the system defaults? Never mind, you can tell simpleGit to use a specific git binary, but it will still use the git-lfs binary on PATH, so I'm not really sure what would be a good way to make this configurable. Modifying the PATH variable would of course work, but it seems a bit outside the scope of this plugin to do.
I've encountered the same issue.
My solution was to manually update the .git/hooks installed by git-lfs (post-commit, post-checkout, post-merge, and pre-push) and add the following line at the top of each one:
PATH="$PATH:/usr/local/bin"
(This assumes that the git-lfs binary resides in /usr/local/bin, which is the case if you installed it through brew by example.)
This will update the PATH variable for the scope of the script and not impact your "usual" PATH, and as such can be considered safe.
Tried the above recommendation but still got errors.
Cannot add files: git-lfs
filter-process: git-lfs: command not found
fatal: the remote end hung up unexpectedly
I checked git-lfs location with which and it was usr/local/bin, added that path line in the top of each hook.. though was I supposed to update them some other way first, or is that what sascha-wolf meant by manually updating? Any other ideas what could be causing it to fail?
This is still an issue as of 2021-09-01
I had the same issue as @frankreporting when I installed git-lfs using homebrew (location was /opt/homebrew/bin).
To resolve it, I installed the package at https://git-lfs.github.com/ and ran install.sh, which installed git-lfs to /usr/local/bin (you may also be able to just move the binary).
After that, I was able to add PATH=$PATH:/usr/local/bin to the git hooks and after restarting Obsidian everything worked.
I've encountered the same issue.
My solution was to manually update the
.git/hooksinstalled bygit-lfs(post-commit,post-checkout,post-merge, andpre-push) and add the following line at the top of each one:PATH="$PATH:/usr/local/bin"(This assumes that the
git-lfsbinary resides in/usr/local/bin, which is the case if you installed it throughbrewby example.)This will update the
PATHvariable for the scope of the script and not impact your "usual"PATH, and as such can be considered safe.
@sascha-wolf Why should I do that? My git-lfs binary is already in the path.
@sascha-wolf Why should I do that? My git-lfs binary is already in the path.
If it works for you, you don't. It didn't for me, git-lfs wasn't in the PATH of the script execution.
Like @frankreporting and @mracette, I was having the same issue where it still wasn't working even after I added PATH="$PATH:/usr/local/bin" to the top of each git hook.
I didn't want to download and install git-lfs manually since I wanted to maintain the management by Homebrew. I was specifically getting an error message about filter-process, and I realized that was part of the filters Git LFS defines in the .gitconfig.
I updated my global .gitconfig to refer to /usr/bin/local/git-lfs instead of just git-lfs on all of the filter lines. That combined with adding PATH="$PATH:/usr/local/bin" to the top of each git hook fixed it for me!
That section of my global .gitconfig now looks like:
[filter "lfs"]
process = /usr/local/bin/git-lfs filter-process
required = true
clean = /usr/local/bin/git-lfs clean -- %f
smudge = /usr/local/bin/git-lfs smudge -- %f
Thanks @christyray, your tip solved it for me!
You can put that section also inside the .git/config file of the Obsidian repo itself, if you don't want to change your global .gitconfig file.
If you don't want to modify gitconfig or git hooks you can create git.sh file in the root dir of your vault or anywhere else you want then specify it as a git command in "Obsidian Git" settings.
#!/bin/bash
# Implementation of git command with Homebrew binaries added to the PATH.
# Needed to make Obsidian Git plugin work with git-lfs. To use this file specify
# the global global path to this file in "Custom Git binary path" setting of "Obsidian Git".
export PATH=$PATH:/usr/local/bin
/usr/local/bin/git "$@"
Works well for me!
Like @frankreporting and @mracette, I was having the same issue where it still wasn't working even after I added
PATH="$PATH:/usr/local/bin"to the top of each git hook.I didn't want to download and install
git-lfsmanually since I wanted to maintain the management by Homebrew. I was specifically getting an error message aboutfilter-process, and I realized that was part of the filters Git LFS defines in the.gitconfig.I updated my global
.gitconfigto refer to/usr/bin/local/git-lfsinstead of justgit-lfson all of the filter lines. That combined with addingPATH="$PATH:/usr/local/bin"to the top of each git hook fixed it for me!That section of my global
.gitconfignow looks like:[filter "lfs"] process = /usr/local/bin/git-lfs filter-process required = true clean = /usr/local/bin/git-lfs clean -- %f smudge = /usr/local/bin/git-lfs smudge -- %f
works for me
I've added a setting to add paths to the PATH env var. Can one of you try the new setting?
I've added a setting to add paths to the PATH env var. Can one of you try the new setting?
@Vinzent03 - The new setting doesn't appear to be updating my path, at least based on the output of process.env.PATH in the console. But, Obsidian now (and possibly for a while - I haven't checked this recently) seems to be using the PATH variable I have set in .zshrc, and that fixed the issues I was having with Git LFS being located.
Same problem, add lfs config to .gitconfig and create git.sh file cannot work
@Vinzent03 Seems to work for me.
Little notch: the path should be specified with the trailing /. Obsidian Git treats it as a path to file (not directory) otherwise.
@AlekseiCherkes You mean the settings description should be improved?
I've added a setting to add paths to the PATH env var. Can one of you try the new setting?
work for me.
Obsidian Git - Advanced - Additional PATH environment variable paths - append /usr/local/bin
@AlekseiCherkes You mean the settings description should be improved?
@Vinzent03 I don't know what's happend exactly, but everything is OK on my side now. I wasn't able to reproduce the issue.
I've added a setting to add paths to the PATH env var. Can one of you try the new setting?
In my case, I had to add /opt/homebrew/bin/ and it worked.
News:
Add /opt/homebrew/bin or your git-lfs path in obsidian-git setting Additional PATH environment variable paths can solve this.
obsidian-gitdon't use my zsh $PATH.
I've added a setting to add paths to the PATH env var. Can one of you try the new setting?
In my case, I had to add
/opt/homebrew/bin/and it worked.
This also worked for me. Thank you!
Adding
/opt/homebrew/bin
in
Obsidian Git > Advanced > Additional PATH environment variable paths
worked for me 👌
Git LFS commit and push now work on Obsidian with git-lfs installed with Homebrew ✅
Adding
/opt/homebrew/binin
Obsidian Git > Advanced > Additional PATH environment variable pathsworked for me 👌
Git LFS commit and push now work on Obsidian with
git-lfsinstalled withHomebrew✅
This also worked for me
