Blame


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.
5 b0e26594 2020-04-02 op
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`:
10 b0e26594 2020-04-02 op
11 a3ab6f61 2020-09-22 op ```gitignore
12 b0e26594 2020-04-02 op *
13 b0e26594 2020-04-02 op ```
14 b0e26594 2020-04-02 op
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.
18 b0e26594 2020-04-02 op
19 44e24c36 2020-04-03 op ---
20 44e24c36 2020-04-03 op
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:
23 44e24c36 2020-04-03 op
24 a3ab6f61 2020-09-22 op ```git
25 44e24c36 2020-04-03 op [core]
26 44e24c36 2020-04-03 op excludesfile = ~/.gitignore
27 44e24c36 2020-04-03 op ```
28 44e24c36 2020-04-03 op
29 44e24c36 2020-04-03 op that was making git ignoring every file in my existings repos.
30 44e24c36 2020-04-03 op
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.
35 44e24c36 2020-04-03 op
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.
38 44e24c36 2020-04-03 op
39 44e24c36 2020-04-03 op ---
40 44e24c36 2020-04-03 op
41 b0e26594 2020-04-02 op Except that this broke all my git repos.
42 b0e26594 2020-04-02 op
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.
46 b0e26594 2020-04-02 op
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.
50 b0e26594 2020-04-02 op
51 b0e26594 2020-04-02 op Fortunately there is a simple solution:
52 a3ab6f61 2020-09-22 op ```sh
53 b0e26594 2020-04-02 op $ cd
54 b0e26594 2020-04-02 op $ mv .gitignore .git/info/exclude
55 b0e26594 2020-04-02 op ```
56 b0e26594 2020-04-02 op
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.