All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 vcsh - Version Control System for $HOME (based on git)
6 1. [30 second howto](#30-second-howto)
7 2. [Introduction](#introduction)
8 3. [Overview](#overview)
9 4. [Getting Started](#getting-started)
11 6. [Contact](#contact)
16 While it may appear that there's an overwhelming amount of documentation and
17 while the explanation of the concepts behind `vcsh` needs to touch a few gory
18 details of `git` internals, getting started with `vcsh` is extremely simple.
20 Let's say you want to version control your `vim` configuration:
23 vcsh vim add ~/.vimrc ~/.vim
24 vcsh vim commit -m 'Initial commit of my Vim configuration'
25 # optionally push your files to a remote
26 vcsh vim remote add origin REMOTE
27 vcsh vim push origin master:master
29 If all that looks a _lot_ like standard `git`, that's no coincidence; it's
32 Once you get familiar with `vcsh`, it's strongly suggested that you look
33 into more advanced usage scenarios, especially on how to manage your
34 `vcsh` and other repositories with [mr][mr].
39 [vcsh][vcsh] allows you to maintain several git repositories in one single
40 directory. They all maintain their working trees without clobbering each other
41 or interfering otherwise. By default, all git repositories maintained via
42 `vcsh` are stored in `$HOME` but you can override this setting if you want to.
43 All this means that you can have one repository per application or application
44 family, i.e. `zsh`, `vim`, `ssh`, etc. This, in turn, allows you to clone
45 custom sets of configurations onto different machines or even for different
46 users; picking and mixing which configurations you want to use where.
47 For example, you may not need to have your `mplayer` configuration on a server
48 or available to root and you may want to maintain different configuration for
49 `ssh` on your personal and your work machines.
51 `vcsh` was designed with [mr][mr], a tool to manage Multiple Repositories, in
52 mind and the two integrate very nicely. `mr` has native support for `vcsh`
53 repositories and to `vcsh`, `mr` is just another configuration to track.
54 This make setting up any new machine a breeze. It takes literally less than
55 five minutes to go from standard installation to fully set up system
57 A lot of modern UNIX-based systems offer pacakges for `vcsh`. In case yours
58 does not read `INSTALL.md` for install instructions or `PACKAGING.md` to create
59 a package, yourself. If you do end up packaging `vcsh` please let us know so we
60 can give you your own packaging branch in the upstream repository.
65 Some people found it useful to look at slides and videos explaining how `vcsh`
66 works instead of working through the docs, first.
67 They can all be found [on the author's talk page][talks].
72 ## Comparison to Other Solutions ##
74 Most people who decide to put their dotfiles under version control start with a
75 single repository in `$HOME`, adding all their dotfiles (and possibly more)
76 to it. This works, of course, but can become a nuisance as soon as you try to
77 manage more than one host.
79 The next logical step is to create single-purpose repositories in, for example,
80 `~/.dotfiles` and to create symbolic links into `$HOME`. This gives you the
81 flexibility to check out only certain repositories on different hosts. The
82 downsides of this approach are the necessary manual steps of cloning and
83 symlinking the individual repositories.
85 `vcsh` takes this second approach one step further. It expects
86 single-purpose repositories and stores them in a hidden directory (similar
87 to `~/.dotfiles`). However, it does not create symbolic links in `$HOME`; it
88 puts the actual files right into `$HOME`.
90 Furthermore, by making use of [mr][mr], it makes it very easy to enable/disable
91 and clone a large number of repositories. The use of `mr` is technically
92 optional (see section 4.3), but it will be an integral part of the proposed
95 ## Default Directory Layout ##
97 To illustrate, this is what a possible directory structure looks like.
100 |-- $XDG_CONFIG_HOME (defaults to $HOME/.config)
104 | | | |-- gitconfigs.vcsh
106 | | | |-- offlineimap.vcsh
110 | | | |-- vimperator.vcsh
111 | | | `-- snippets.git
113 | | |-- zsh.vcsh -> ../available.d/zsh.vcsh
114 | | |-- gitconfigs.vcsh -> ../available.d/gitconfigs.vcsh
115 | | |-- tmux.vcsh -> ../available.d/tmux.vcsh
116 | | `-- vim.vcsh -> ../available.d/vim.vcsh
120 | |-- zsh.git -----------+
121 | |-- gitconfigs.git |
125 |-- .zshrc <----------------------+
133 The files you see in $XDG\_CONFIG\_HOME/mr/available.d are mr configuration files
134 that contain the commands to manage (checkout, update etc.) a single
135 repository. vcsh repo configs end in .vcsh, git configs end in .git, etc. This
136 is optional and your preference. For example, this is what a zsh.vcsh
137 with read-only access to my zshrc repo looks likes. I.e. in this specific
138 example, push can not work as you will be using the author's repository. This
139 is for demonstration, only. Of course, you are more than welcome to clone from
140 this repository and fork your own.
142 [$XDG_CONFIG_HOME/vcsh/repo.d/zsh.git]
143 checkout = vcsh clone 'git://github.com/RichiH/zshrc.git' zsh
144 update = vcsh run zsh git pull
145 push = vcsh run zsh git push
146 status = vcsh run zsh git status
147 gc = vcsh run zsh git gc
151 $XDG\_CONFIG\_HOME/mr/available.d contains *all available* repositories. Only
152 files/links present in mr/config.d, however, will be used by mr. That means
153 that in this example, only the zsh, gitconfigs, tmux and vim repositories will
154 be checked out. A simple `mr update` run in $HOME will clone or update those
155 four repositories listed in config.d.
159 Finally, ~/.mrconfig will tie together all those single files which will allow
160 you to conveniently run `mr up` etc. to manage all repositories. It looks like
165 # Use if your mr does not have vcsh support in mainline, yet
166 include = cat /usr/share/mr/vcsh
167 include = cat ${XDG_CONFIG_HOME:-$HOME/.config}/mr/config.d/*
171 $XDG\_CONFIG\_HOME/vcsh/repo.d is the directory where all git repositories which
172 are under vcsh's control are located. Since their working trees are configured
173 to be in $HOME, the files contained in those repositories will be put in $HOME
175 Of course, [mr] [1] will work with this layout if configured according to this
176 document (see above).
178 vcsh will check if any file it would want to create exists. If it exists, vcsh
179 will throw a warning and exit. Move away your old config and try again.
180 Optionally, merge your local and your global configs afterwards and push with
181 `vcsh run foo git push`.
183 ## Moving into a New Host ##
185 To illustrate further, the following steps could move your desired
186 configuration to a new host.
188 1. Clone the mr repository (containing available.d, config.d etc.); for
189 example: `vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr`
190 2. Choose your repositories by linking them in config.d (or go with the default
191 you may have already configured by adding symlinks to git).
192 3. Make sure the line 'include = cat /usr/share/mr/vcsh' in .mrconfig points
194 4. Run mr to clone the repositories: `cd; mr update`.
197 Hopefully the above could help explain how this approach saves time by
199 1. making it easy to manage, clone and update a large number of repositories
201 2. making it unnecessary to create symbolic links in $HOME (thanks to vcsh).
203 If you want to give vcsh a try, follow the instructions below.
208 Below, you will find a few different methods for setting up vcsh:
211 2. The Steal-from-Template Way
214 ### The Template Way ###
216 #### Prerequisites ####
218 Make sure none of the following files and directories exist for your test
219 (user). If they do, move them away for now:
223 * $XDG\_CONFIG\_HOME/mr/available.d/mr.vcsh
224 * $XDG\_CONFIG\_HOME/mr/available.d/zsh.vcsh
225 * $XDG\_CONFIG\_HOME/mr/config.d/mr.vcsh
226 * $XDG\_CONFIG\_HOME/vcsh/repo.d/mr.git/
228 All of the files are part of the template repository, the directory is where
229 the template will be stored.
233 #### Install vcsh ####
237 If you are using Debian Squeeze, you will need to enable backports
243 vcsh is availabe via [AUR](https://aur.archlinux.org/packages.php?ID=54164)
244 and further documentation about the use of AUR is available
245 [on Arch's wiki](https://wiki.archlinux.org/index.php/Arch_User_Repository).
248 wget https://aur.archlinux.org/packages/vc/vcsh-git/vcsh-git.tar.gz
249 tar xfz vcsh-git.tar.gz
252 pacman -U vcsh*.pkg.tar.xz
254 #### From source ####
256 If your version of mr is older than version 1.07, make sure to put
258 include = cat /usr/share/mr/vcsh
260 into your .mrconfig .
262 # choose a location for your checkout
265 git clone git://github.com/RichiH/vcsh.git
267 ln -s vcsh /usr/local/bin # or add it to your PATH
270 #### Clone the Template ####
272 vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr
274 #### Enable Your Test Repository ####
277 mv ~/.zshrc ~/zshrc.bak
278 cd $XDG_CONFIG_HOME/mr/config.d/
279 ln -s ../available.d/zsh.vcsh . # link, and thereby enable, the zsh repository
283 #### Set Up Your Own Repositories ####
285 Now, it's time to edit the template config and fill it with your own remotes:
287 vim $XDG_CONFIG_HOME/mr/available.d/mr.vcsh
288 vim $XDG_CONFIG_HOME/mr/available.d/zsh.vcsh
290 And then create your own stuff:
293 vcsh run foo git add -f bar baz quux
294 vcsh run foo git remote add origin git://quuux
295 vcsh run foo git commit
296 vcsh run foo git push
298 cp $XDG_CONFIG_HOME/mr/available.d/mr.vcsh $XDG_CONFIG_HOME/mr/available.d/foo.vcsh
299 vim $XDG_CONFIG_HOME/mr/available.d/foo.vcsh # add your own repo
303 ### The Steal-from-Template Way ###
305 You're welcome to clone the example repository:
307 vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr
308 # make sure 'include = cat /usr/share/mr/vcsh' points to an exiting file
311 Look around in the clone. It should be reasonably simple to understand. If not,
312 poke me, RichiH, on Freenode (query) or OFTC (#vcs-home).
315 ### The Manual Way ###
317 This is how my old setup procedure looked like. Adapt it to your own style or
318 copy mine verbatim, either is fine.
324 # Clone vcsh and make it available
325 git clone git://github.com/RichiH/vcsh.git vcsh
326 sudo ln -s ~/work/git/vcsh/vcsh /usr/bin/local
329 Grab my mr config. see below for details on how I set this up
331 vcsh clone ssh://<remote>/mr.git
332 cd $XDG_CONFIG_HOME/mr/config.d/
333 ln -s ../available.d/* .
336 mr is used to actually retrieve configs, etc
340 # adapt /usr/share/mr/vcsh to your system if needed
341 include = cat /usr/share/mr/vcsh
342 include = cat $XDG_CONFIG_HOME/mr/config.d/*
343 ~ % echo $XDG_CONFIG_HOME
345 ~ % ls $XDG_CONFIG_HOME/mr/available.d # random selection of my repos
346 git-annex gitk.vcsh git.vcsh ikiwiki mr.vcsh reportbug.vcsh snippets.git wget.vcsh zsh.vcsh
348 # then simply ln -s whatever you want on your local machine from
349 # $XDG_CONFIG_HOME/mr/available.d to $XDG_CONFIG_HOME/mr/config.d
356 ### Keeping repositories Up-to-Date ###
358 This is the beauty of it all. Once you are set up, just run:
365 ### Making Changes ###
367 After you have made some changes, for which you would normally use `git add`
368 and `git commit`, use the vcsh wrapper (like above):
370 vcsh run foo git add -f bar baz quux
371 vcsh run foo git commit
372 vcsh run foo git push
374 By the way, you'll have to use -f/--force flag with git-add because all files
375 will be ignored by default. This is to show you only useful output when running
376 git-status. A fix for this problem is being worked on.
378 ### Using vcsh without mr ###
380 vcsh encourages you to use [mr] [1]. It helps you manage a large number of
381 repositories by running the necessary vcsh commands for you. You may choose not
382 to use mr, in which case you will have to run those commands manually or by
385 #### A Few Examples ####
387 To initialize a new repository: `vcsh init zsh`
389 To clone a repository: `vcsh clone ssh://<remote>/zsh.git`
391 To interact with a repository, use the regular Git commands, but prepend them
392 with `vcsh run $repository_name`. For example:
394 vcsh run zsh git status
395 vcsh run zsh git add -f .zshrc
396 vcsh run zsh git commit
398 Obviously, without mr keeping repositories up-to-date, it will have to be done
399 manually. Alternatively, you could try something like this:
401 for repo in `vcsh list`; do
402 vcsh run $repo git pull;
408 There are several ways to get in touch with the author and a small but committed
409 community around the general idea of version controlling your (digital) life.
411 * IRC: #vcs-home on irc.oftc.net
413 * Mailing list: [http://lists.madduck.net/listinfo/vcs-home][vcs-home-list]
415 * Pull requests or issues on [https://github.com/RichiH/vcsh][vcsh]
418 [mr]: http://kitenet.net/~joey/code/mr/
419 [talks]: http://richardhartmann.de/talks/
420 [vcsh]: https://github.com/RichiH/vcsh
421 [vcs-home-list]: http://lists.madduck.net/listinfo/vcs-home