1 b0e26594 2020-04-02 op I finally decided to track my dotfiles on a git repository. This
2 b0e26594 2020-04-02 op should make things simpler when migrating to another machine, as well
3 b0e26594 2020-04-02 op as having consistent configuration across various computers. We'll
4 b0e26594 2020-04-02 op see how well it will go for me.
6 b0e26594 2020-04-02 op I've done a bit of research on the internet and I've found
7 b0e26594 2020-04-02 op [this](https://drewdevault.com/2019/12/30/dotfiles.html). The author
8 b0e26594 2020-04-02 op of that post suggest to use your whole $HOME as a git repository, with
9 b0e26594 2020-04-02 op a one-byte `.gitignore`:
15 b0e26594 2020-04-02 op While the mine is actually two-bytes long due to a newline, this got
16 b0e26594 2020-04-02 op me started. Git will ignore everything (music, documents, logs...)
17 b0e26594 2020-04-02 op except files that you add with `-f`. So far so good.
21 44e24c36 2020-04-03 op **edit**: the part that follows is mostly wrong. The problem I had
22 a3ab6f61 2020-09-22 op was due to this piece of my global git config:
26 44e24c36 2020-04-03 op excludesfile = ~/.gitignore
29 44e24c36 2020-04-03 op that was making git ignoring every file in my existings repos.
31 44e24c36 2020-04-03 op Why I had that thing in the first place? Well, it's the result of
32 44e24c36 2020-04-03 op migrating to this machine. I had a global gitignore file in my home
33 44e24c36 2020-04-03 op directory to ignore common files (like emacs backups, acme guide files
34 44e24c36 2020-04-03 op and so on), that I forgot to copy on the new machine.
36 44e24c36 2020-04-03 op I've kept the rest of the post because of the `.git/info/exclude` bit
37 44e24c36 2020-04-03 op that I didn't known about.
41 b0e26594 2020-04-02 op Except that this broke all my git repos.
43 b0e26594 2020-04-02 op I have several git repositories in subfolders inside my home, and
44 b0e26594 2020-04-02 op since git goes recursively when searching for `.gitignore`s it will
45 44e24c36 2020-04-03 op ignore EVERY file.
47 b0e26594 2020-04-02 op Maybe the author has his `~/build` or `~/src` mounted with NFS or
48 b0e26594 2020-04-02 op something else (git should stop at filesystem boundaries AFAIK), but
49 b0e26594 2020-04-02 op this isn't my case.
51 b0e26594 2020-04-02 op Fortunately there is a simple solution:
54 b0e26594 2020-04-02 op $ mv .gitignore .git/info/exclude
57 b0e26594 2020-04-02 op This way, for your `~` repository, git will exclude files listed on
58 b0e26594 2020-04-02 op `~/.git/info/exclude` (that is, every file not manually added), while
59 b0e26594 2020-04-02 op behaving normally on every repository you have inside your home.