commit b0e2659430fdbc9c7879d345cef4be4dc0438075 from: Omar Polo date: Thu Apr 02 09:58:59 2020 UTC new post "$HOME as a git repo" commit - cbac00875c9973e6a6bcf86d8c5304643006f410 commit + b0e2659430fdbc9c7879d345cef4be4dc0438075 blob - /dev/null blob + 763a1916b99bc02731e343d05ddaa8b223c5f04f (mode 644) --- /dev/null +++ resources/posts/home-as-git-repo.md @@ -0,0 +1,38 @@ +I finally decided to track my dotfiles on a git repository. This +should make things simpler when migrating to another machine, as well +as having consistent configuration across various computers. We'll +see how well it will go for me. + +I've done a bit of research on the internet and I've found +[this](https://drewdevault.com/2019/12/30/dotfiles.html). The author +of that post suggest to use your whole $HOME as a git repository, with +a one-byte `.gitignore`: + +``` +* +``` + +While the mine is actually two-bytes long due to a newline, this got +me started. Git will ignore everything (music, documents, logs...) +except files that you add with `-f`. So far so good. + +Except that this broke all my git repos. + +I have several git repositories in subfolders inside my home, and +since git goes recursively when searching for `.gitignore`s it will +ignore EVERY file. (this shouldn't be a surprise, but I thought +`.gitignore` were per-repo) + +Maybe the author has his `~/build` or `~/src` mounted with NFS or +something else (git should stop at filesystem boundaries AFAIK), but +this isn't my case. + +Fortunately there is a simple solution: +``` +$ cd +$ mv .gitignore .git/info/exclude +``` + +This way, for your `~` repository, git will exclude files listed on +`~/.git/info/exclude` (that is, every file not manually added), while +behaving normally on every repository you have inside your home. blob - ecbe3ee64308a453119a7768253b1226fd3966db blob + f868dada00098778d48f7a88af32a94ec063c647 --- src/blog/posts.clj +++ src/blog/posts.clj @@ -1,3 +1,9 @@ +(add-post! {:title "$HOME as a git repo" + :slug "home-as-git-repo" + :date "2020/04/02" + :tags #{:git} + :short "How do you track dotfiles?"}) + (comment (add-post! {:title "Blogging with clojure" :slug "blogging-with-clojure"