3 ms·
One potential drawback of doing that is that every directory under ~/ that is not itself part of another git repository becomes part of that git repository, whi
by seri4l 4y ago
One potential drawback of doing that is that every directory under ~/ that is not itself part of another git repository becomes part of that git repository, which could make some programs act weird, particularly project auto-detectors in IDEs and such.
To avoid that, one can rename the `.git` folder, effectively disabling auto-discovery, and run git with the option `--git-dir=<newname>`.
- Cyberdog 4y agoSo the IDE or whatever would basically traverse up the filesystem looking for the first directory with a .git subdirectory? I've never encountered something like that but I suppose it's possible. Do you know of any IDEs specifically that do that? At any rate, I didn't know renaming the .git directory was possible. Do you have to add the --git-dir option to every subsequent git command? Sounds like a pain but my dotfiles change rarely enough that I guess I could live with it if I had to.
- gryn 4y agoyou can also create a .git file with the path for the git-dir folder (git-dir: /path-to-git-folder/) but that is kind of like having the .git folder with the exception that some programs don't seem to support it.
- seri4l 4y agoYeah, the git command traverses up the filesystem until it finds a ./.git/HEAD file or until it reaches /, whatever happens first. The problem comes when a 3rd program uses git to find the root of a project that doesn't exist and instead of failing finds ~/.git and naively decides to index everything under ~/. I don't know of any specific IDEs that do that, although I vaguely remember running into a similar issue in the past, maybe not with an IDE, which is probably why I do it that way.
- grumbel 4y agoIn `~/.git/config` do: [status] showUntrackedFiles = no That solves most of those problems, as git will only consider files already in the repository and ignore everything else in your home directory.