0

I’m keeping track of my dotfiles with a git repository under $HOME/.dotfiles which is configured to track files in $HOME (I used git config core.worktree "../../").

This method works fine as long as regular files are concerned, but it fails when I try to add a submodule. Eg:

~/.dotfiles $ git submodule add git@github.com:ardagnir/vimbed.git ../../.vim/bundle/vimbed/
fatal: Not a git repository (or any parent up to mount point /home)       
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

I also tried ../.vim/... and $HOME/.vim/....

Is it possible to add a submodule when core.worktree is set to a parent of the repo’s default directory? If so, how what command should I use?

Arcturus B
  • 5,181
  • 4
  • 31
  • 51

3 Answers3

0

Why would you like to track your entire $HOME directory? It would be more reasonable to maintain all dotfiles in your .dotfiles folder/repo and then symlink those files to your home, e.g. create a folder $HOME/.dotfiles/vim with your config and submodule(s) and then link it to $HOME/.vim

You could also easily use a setup script for your dotfiles, that backs up your previous config and then links your dotfiles into $HOME.

j. doe
  • 41
  • 2
0

I have not tried with git submodule, but for git stash setting the environment variable $GIT_DIR or using argument --git-dir works. For example, git --git-dir=./.git stash (seems silly this is even necessary).

See: https://git-scm.com/docs/git.html or https://stackoverflow.com/posts/6392941/edit

dontarius
  • 99
  • 1
  • 8
0

git submodules DO NOT follow core.worktree settings — try:

git --git-dir="$HOME/dotfiles" --work-tree="$HOME"
Rafael
  • 7,605
  • 13
  • 31
  • 46
t00r
  • 1
  • 1