Comments on 2021-05-09 Version control for beginners

An alternative to changing relevant files to symlinks in your home directory is to simply make ~/ a git repository.

The problem is that git status by default shows all files it doesn’t know about as “untracked” - but that can be remedied by adding:

    showuntrackedfiles = no

to your ~/.git/config.

The upside is that you don’t have to move the file, make a symlink, and go somewhere else to commit.

I use this “trick” in / on all my machines to keep track of configuration files I change.

Adam 2021-05-09 09:45 UTC

Interesting, thanks. I did not know about not showing untracked files. Does that work well if some of your subdirectories are again git repositories?

– Alex 2021-05-09 10:45 UTC

Yes, it works fine - I have plenty of git repositories in subfolders.

git will look for .git/ in the current directory, then the parent, then the grandparent etc. until it finds one, and that defines what repository you are “in”.

The only catch is that if you think you are in a git repo in a subfolder, and isn’t actually a repo, then you’re in a subfolder of the top/parent repository. In practice this very seldom confuses me; I might be weird that way, though.

Adam 2021-05-11 21:00 UTC

To avoid the potential confusion with Adam’s trick you can use a different name for the .git folder at your top level directory. I have the following alias I use to manage all my user level configuration files, etc.:

home='git --git-dir="${HOME}/.home-git" --work-tree="${HOME}"'

To set it up, go to your home directory and git init && rename .git .home-git (or maybe you could just do home init?). From then on use home for you config files, and git for everything else.

(I’m not sure why I added that --work-tree option is/was important… it may have been related to when I didn’t have the same username on all computers?)

– Björn Buckwalter 2021-05-14 17:05 UTC

Ending up with two different commands for the two kinds of repositories is a great idea.

Definitely a level tinkering that goes beyond “for beginners”, though! 😀

– Alex 2021-05-14 18:18 UTC

Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit this page if you need to fix typos. You can subscribe to updates by email without leaving a comment.

To save this page you must answer this question:

Just say HELLO