Blob


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