points by StreakyCobra 10 years ago

I use:

    git init --bare $HOME/.myconf
    alias config='/usr/bin/git --git-dir=$HOME/.myconf/ --work-tree=$HOME'
    config config status.showUntrackedFiles no

where my ~/.myconf directory is a git bare repository. Then any file within the home folder can be versioned with normal commands like:

    config status
    config add .vimrc
    config commit -m "Add vimrc"
    config add .config/redshift.conf
    config commit -m "Add redshift config"
    config push

And so one…

No extra tooling, no symlinks, files are tracked on a version control system, you can use different branches for different computers, you can replicate you configuration easily on new installation.

seliopou 10 years ago

To complete the description of the workflow (for others), you can replicate your home directory on a new machine using the following command:

   git clone --separate-git-dir=~/.myconf /path/to/repo ~

This is the best solution I've seen so far, and I may adopt it next time I get the itch to reconfigure my environment.

  • telotortium 10 years ago

    For posterity, note that this will fail if your home directory isn't empty. To get around that, clone the repo's working directory into a temporary directory first and then delete that directory,

        git clone --separate-git-dir=$HOME/.myconf /path/to/repo $HOME/myconf-tmp
        cp ~/myconf-tmp/.gitmodules ~  # If you use Git submodules
        rm -r ~/myconf-tmp/
        alias config='/usr/bin/git --git-dir=$HOME/.myconf/ --work-tree=$HOME'
    

    and then proceed as before.

    • durdn 10 years ago

      I found out exactly the same problem :)

aprdm 10 years ago

Can you write a blog post on your workflow? I would love to learn more on how you to use it :P

  • durdn 10 years ago

    I'm trying to reproduce it and documenting it as I go... ok I got it working now and I have notes. Stay tuned.

    • StreakyCobra 10 years ago

      It's probably better if you do it then :-) I would probably skip some important parts trying to explain because I'm too much used to it already.

      • durdn 10 years ago

        Working on it! I'll give you full credit for it and link to this thread for reference. Also let me know if you have a Twitter account you'd like me to reference.

        • StreakyCobra 10 years ago

          Nice thanks. I don't have twitter. Also don't present me as the inventor of this technique because I'm not. I've read this long time ago on some dark corners of the internet :-) I'm just pointing it out.

          • durdn 10 years ago

            Alright I'll be careful in my wording ;).

  • StreakyCobra 10 years ago

    There are probably already posts about this: I didn't invented it, I read it somewhere… but it was long time ago, I don't remember where.

prima-facie 10 years ago

Why is this a bare repo as opposed to a normal one?

  • StreakyCobra 10 years ago

    Because the working tree is already your home folder, you don't need to also have a copy of these files in ".myconf/".

    • idle_zealot 10 years ago

      So why use .myconf/ at all? What is it doing?

      • telotortium 10 years ago

        It contains the files that would normally be in .git (run `git help gitrepository-layout` for more details on the contents).

durdn 10 years ago

Honestly this is genius! I hadn't thought of doing it like that, thank you! I had resorted to the usual .cfg folder and a helper script to link/update everything.

  • shabda 10 years ago

    Could you explain how this works? Won't this be putting the .bashrc in $HOME/.myconf/.bashrc, which won't get picked up by bash? (And similar for other dotfiles)

    • nindalf 10 years ago

      You could add a symlink in your $HOME folder

    • unwind 10 years ago

      No, since the config alias runs git with the option "--work-tree=$HOME", which tells it that the working directory is your home directory root, i.e. where config files (used to) live.

      Anyway it's the proper root for config files, since if you use a .config directory (as seems to be the modern choice) that needs to live in your home directory of course.

qznc 10 years ago

"branches for different computers" sounds tedious if most changes are for every computer.

  • StreakyCobra 10 years ago

    I have a "master" branch, and some "computer" branches. When changes are required for all computer, I do it in "master", and then update each branch by doing a "git merge master".

kavehmz 10 years ago

You mean, you are also adding pushing your .ssh dir to a remote repo?

  • durdn 10 years ago

    Not at all. You can 'git add' (or in the case of the technique above 'config add') only the files and folders that are safely stored in a repository. Because of the 'ShowUntrackedFiles' flag, git/config won't always show folders you don't want to track, which would be annoying.

    • kavehmz 10 years ago

      Perfect then,

abricot 10 years ago

I'm confused - you can add files that are in a parent directory?

  • StreakyCobra 10 years ago

    It's because we specify to git that the working tree is the home folder. For it the versionning doesn't happen in ".myconf", but directly in the home folder