for those who don't know, TopGit[1] is a patch management system on top
of git; basically what it offers is an easy way to track dependencies
between git branches and export them to patches, so I tried to use it to
manage my dot-files using one branch per program (a branch for vim
files, a branch for bash files, etc.) having them merged together like
in a "union" operation into a single branch.

I wrote a Makefile (attached) to automate some tasks, and I've written a
tutorial explaining how it works, temporarily here:

I am also attaching the .txt version of the tutorial in case you want
to quote something from it on reply.

This is meant mainly for discussion as I still see some fragility in
this approach, maybe on the long run having topgit messing up with
the history could even nullify the point of having the files under
version control at all; and I have also some doubts about working on
such a repository in a collaborative way.

Anyhow, I spent some hours putting the experiment together and I just
wanted to share it and ask for your opinion, as there are people here
who have been thinking to similar problems for a longer time than I

I suspect I'll end up putting all my dot-files in a single repository
with a rather flat structure, eventually :)


[1] http://repo.or.cz/w/topgit.git

Antonio Ospite

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
DotFiles with TopGit
Antonio Ospite <osp...@studenti.unina.it>
v1.0, March 2011:
First version.

An experiment on managing dot-files with TopGit


  - Manage different sets of configuration files in one repository
  - Avoid calling programs other than make and git directly as far as 
  - Have private or “local” configuration files
  - Have a .gitignore file for generated files
  - Copy configuration files to remote hosts


  - I don't need to track the files directly into '$HOME': keeping a 
    copy around is fine as long as I can easily diff with the actual 
    files in '$HOME'

The sets of configurations files will be represented with git branches, 
and a few special branches will perform a "union" operations on these 
sets producing something resembling what we want to track in the '$HOME'

TopGit has to be used by those who want to push to the remote repository
eventually, but will not be needed for those who just want to clone the
repository to reuse what is in it.

The drawback of using TopGit is that the history gets polluted with a 
lot of Merge commits, but using 'git log --no-merges' alleviate this 



  - lines starting with '$' are shell commands
  - the symbol '*' in the branch layouts marks the currently active 
  - if the prompt looks like '[branch-name]' this is a topgit prompt 
    shown when there are conflicts to solve

Initialize the repository

  $ make init

Start tracking vim dot files

  $ make add-vim

We get the branch layout below

    | dot-files  |
   | * tg/dot-vim |
    |   master   |

and we can now start tracking vim configuration files

  $ cp ~/.vimrc dot-vimrc
  $ cp -r ~/.vim dot-vim
  $ git add dot-*
  $ git commit

Start tracking bash dot files

  $ make add-bash

We get the layout below:

           | dot-files  |
              /     \
             /       \
            v         v
   +------------+ +---------------+
   | tg/dot-vim | | * tg/dot-bash |
   +------------+ +---------------+
            \        /
             \      /
              v    v
           |   master   |

and we ca start tracking bash confiration files

  $ cp ~/.bashrc dot-bashrc
  $ cp ~/.bash_profile dot-bash_profile
  $ cp ~/.inpurtc dot-inputrc
  $ git add dot-*
  $ git commit

Update the "union" branch

Update the topmost branch called 'dot-files' and install the 
configurations files

  $ make update

Check what are the differences between what is in the repository and 
what is in '$HOME':
  $ make diff

Finally install the version in the repsoitory replacing the on ein 

  $ make install

Start a local bash branch
  $ make local-bash

We get the layout below:

           | dot-files-local |
              |        \
              |         \
              |          v
              |      +---------------------+
              |      | * tg/dot-bash-local |
              |      +---------------------+
              v              |
           +------------+    |
           | dot-files  |    |
           +------------+    |
              /     \        |
             /       \       |
            v         v      v
    +------------+ +-------------+
    | tg/dot-vim | | tg/dot-bash |
    +------------+ +-------------+
            \        /
             \      /
              v    v
           |   master   |

Add some personal setting

  $ echo "[ -e .bashrc-local ] && source .bashrc-local" >> dot-bashrc
  $ echo "DEBEMAIL=m...@home.net" > dot-bashrc-local
  $ git add dot-bashrc-local
  $ git commit -m "Add a local bashrc"

Update all the configurations

This will update the 'dot-files-local' branch and all its
dependencies and install all the configurations files.

  $ make update-all
  $ make install

Push all the changes to a remote repository

  $ make push

This will *NOT* push the local stuff to the public repository

Resolving merge conflicts

In particular if you change Makefile or README.txt while in the master 
branch, you are likely to get conflicts when calling 'make update'.

To solve this keeping the changes from master just run these commands at 
the topgit prompt:

  [tg/dot-vim] git checkout --their Makefile README.txt
  [tg/dot-vim] git add Makefile README.txt
  [tg/dot-vim] git commit
  [tg/dot-vim] exit

Attachment: pgpn0irQA2EPn.pgp
Description: PGP signature

vcs-home mailing list

Reply via email to