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)
8 3. [Introduction](#introduction)
9 4. [Overview](#overview)
10 5. [Getting Started](#getting-started)
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 There are several ways to get in touch with the author and a small but committed
40 community around the general idea of version controlling your (digital) life.
42 * IRC: #vcs-home on irc.oftc.net
44 * Mailing list: [http://lists.madduck.net/listinfo/vcs-home][vcs-home-list]
46 * Pull requests or issues on [https://github.com/RichiH/vcsh][vcsh]
51 [vcsh][vcsh] allows you to maintain several git repositories in one single
52 directory. They all maintain their working trees without clobbering each other
53 or interfering otherwise. By default, all git repositories maintained via
54 `vcsh` are stored in `$HOME` but you can override this setting if you want to.
55 All this means that you can have one repository per application or application
56 family, i.e. `zsh`, `vim`, `ssh`, etc. This, in turn, allows you to clone
57 custom sets of configurations onto different machines or even for different
58 users; picking and mixing which configurations you want to use where.
59 For example, you may not need to have your `mplayer` configuration on a server
60 or available to root and you may want to maintain different configuration for
61 `ssh` on your personal and your work machines.
63 `vcsh` was designed with [mr][mr] in mind so you might want to install that, as
66 Read `INSTALL.md` and `PACKAGING.md` for instructions specific to your operating
69 The following overview will try to give you an idea of the use cases and
70 advantages of `vcsh`. See sections 3 and 4 for detailed instructions and
75 Some people found it useful to look at slides and videos explaining how `vcsh`
77 They can all be found [on the author's talk page][talks].
82 ## Comparison to Other Solutions ##
84 Most people who decide to put their dotfiles under version control start with a
85 single repository in `$HOME`, adding all their dotfiles (and possibly more)
86 to it. This works, of course, but can become a nuisance as soon as you try to
87 manage more than one host.
89 The next logical step is to create single-purpose repositories in, for example,
90 `~/.dotfiles` and to create symbolic links into `$HOME`. This gives you the
91 flexibility to check out only certain repositories on different hosts. The
92 downsides of this approach are the necessary manual steps of cloning and
93 symlinking the individual repositories.
95 `vcsh` takes this second approach one step further. It expects
96 single-purpose repositories and stores them in a hidden directory (similar
97 to `~/.dotfiles`). However, it does not create symbolic links in `$HOME`; it
98 puts the actual files right into `$HOME`.
100 Furthermore, by making use of [mr][mr], it makes it very easy to enable/disable
101 and clone a large number of repositories. The use of `mr` is technically
102 optional (see section 4.3), but it will be an integral part of the proposed
105 ## Default Directory Layout ##
107 To illustrate, this is what a possible directory structure looks like.
110 |-- $XDG_CONFIG_HOME (defaults to $HOME/.config)
114 | | | |-- gitconfigs.vcsh
116 | | | |-- offlineimap.vcsh
120 | | | |-- vimperator.vcsh
121 | | | `-- snippets.git
123 | | |-- zsh.vcsh -> ../available.d/zsh.vcsh
124 | | |-- gitconfigs.vcsh -> ../available.d/gitconfigs.vcsh
125 | | |-- tmux.vcsh -> ../available.d/tmux.vcsh
126 | | `-- vim.vcsh -> ../available.d/vim.vcsh
130 | |-- zsh.git -----------+
131 | |-- gitconfigs.git |
135 |-- .zshrc <----------------------+
143 The files you see in $XDG\_CONFIG\_HOME/mr/available.d are mr configuration files
144 that contain the commands to manage (checkout, update etc.) a single
145 repository. vcsh repo configs end in .vcsh, git configs end in .git, etc. This
146 is optional and your preference. For example, this is what a zsh.vcsh
147 with read-only access to my zshrc repo looks likes. I.e. in this specific
148 example, push can not work as you will be using the author's repository. This
149 is for demonstration, only. Of course, you are more than welcome to clone from
150 this repository and fork your own.
152 [$XDG_CONFIG_HOME/vcsh/repo.d/zsh.git]
153 checkout = vcsh clone 'git://github.com/RichiH/zshrc.git' zsh
154 update = vcsh run zsh git pull
155 push = vcsh run zsh git push
156 status = vcsh run zsh git status
157 gc = vcsh run zsh git gc
161 $XDG\_CONFIG\_HOME/mr/available.d contains *all available* repositories. Only
162 files/links present in mr/config.d, however, will be used by mr. That means
163 that in this example, only the zsh, gitconfigs, tmux and vim repositories will
164 be checked out. A simple `mr update` run in $HOME will clone or update those
165 four repositories listed in config.d.
169 Finally, ~/.mrconfig will tie together all those single files which will allow
170 you to conveniently run `mr up` etc. to manage all repositories. It looks like
175 # Use if your mr does not have vcsh support in mainline, yet
176 include = cat /usr/share/mr/vcsh
177 include = cat ${XDG_CONFIG_HOME:-$HOME/.config}/mr/config.d/*
181 $XDG\_CONFIG\_HOME/vcsh/repo.d is the directory where all git repositories which
182 are under vcsh's control are located. Since their working trees are configured
183 to be in $HOME, the files contained in those repositories will be put in $HOME
185 Of course, [mr] [1] will work with this layout if configured according to this
186 document (see above).
188 vcsh will check if any file it would want to create exists. If it exists, vcsh
189 will throw a warning and exit. Move away your old config and try again.
190 Optionally, merge your local and your global configs afterwards and push with
191 `vcsh run foo git push`.
193 ## Moving into a New Host ##
195 To illustrate further, the following steps could move your desired
196 configuration to a new host.
198 1. Clone the mr repository (containing available.d, config.d etc.); for
199 example: `vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr`
200 2. Choose your repositories by linking them in config.d (or go with the default
201 you may have already configured by adding symlinks to git).
202 3. Make sure the line 'include = cat /usr/share/mr/vcsh' in .mrconfig points
204 4. Run mr to clone the repositories: `cd; mr update`.
207 Hopefully the above could help explain how this approach saves time by
209 1. making it easy to manage, clone and update a large number of repositories
211 2. making it unnecessary to create symbolic links in $HOME (thanks to vcsh).
213 If you want to give vcsh a try, follow the instructions below.
218 Below, you will find a few different methods for setting up vcsh:
221 2. The Steal-from-Template Way
224 ### The Template Way ###
226 #### Prerequisites ####
228 Make sure none of the following files and directories exist for your test
229 (user). If they do, move them away for now:
233 * $XDG\_CONFIG\_HOME/mr/available.d/mr.vcsh
234 * $XDG\_CONFIG\_HOME/mr/available.d/zsh.vcsh
235 * $XDG\_CONFIG\_HOME/mr/config.d/mr.vcsh
236 * $XDG\_CONFIG\_HOME/vcsh/repo.d/mr.git/
238 All of the files are part of the template repository, the directory is where
239 the template will be stored.
243 #### Install vcsh ####
247 If you are using Debian Squeeze, you will need to enable backports
253 vcsh is availabe via [AUR](https://aur.archlinux.org/packages.php?ID=54164)
254 and further documentation about the use of AUR is available
255 [on Arch's wiki](https://wiki.archlinux.org/index.php/Arch_User_Repository).
258 wget https://aur.archlinux.org/packages/vc/vcsh-git/vcsh-git.tar.gz
259 tar xfz vcsh-git.tar.gz
262 pacman -U vcsh*.pkg.tar.xz
264 #### From source ####
266 If your version of mr is older than version 1.07, make sure to put
268 include = cat /usr/share/mr/vcsh
270 into your .mrconfig .
272 # choose a location for your checkout
275 git clone git://github.com/RichiH/vcsh.git
277 ln -s vcsh /usr/local/bin # or add it to your PATH
280 #### Clone the Template ####
282 vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr
284 #### Enable Your Test Repository ####
287 mv ~/.zshrc ~/zshrc.bak
288 cd $XDG_CONFIG_HOME/mr/config.d/
289 ln -s ../available.d/zsh.vcsh . # link, and thereby enable, the zsh repository
293 #### Set Up Your Own Repositories ####
295 Now, it's time to edit the template config and fill it with your own remotes:
297 vim $XDG_CONFIG_HOME/mr/available.d/mr.vcsh
298 vim $XDG_CONFIG_HOME/mr/available.d/zsh.vcsh
300 And then create your own stuff:
303 vcsh run foo git add -f bar baz quux
304 vcsh run foo git remote add origin git://quuux
305 vcsh run foo git commit
306 vcsh run foo git push
308 cp $XDG_CONFIG_HOME/mr/available.d/mr.vcsh $XDG_CONFIG_HOME/mr/available.d/foo.vcsh
309 vim $XDG_CONFIG_HOME/mr/available.d/foo.vcsh # add your own repo
313 ### The Steal-from-Template Way ###
315 You're welcome to clone the example repository:
317 vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr
318 # make sure 'include = cat /usr/share/mr/vcsh' points to an exiting file
321 Look around in the clone. It should be reasonably simple to understand. If not,
322 poke me, RichiH, on Freenode (query) or OFTC (#vcs-home).
325 ### The Manual Way ###
327 This is how my old setup procedure looked like. Adapt it to your own style or
328 copy mine verbatim, either is fine.
334 # Clone vcsh and make it available
335 git clone git://github.com/RichiH/vcsh.git vcsh
336 sudo ln -s ~/work/git/vcsh/vcsh /usr/bin/local
339 Grab my mr config. see below for details on how I set this up
341 vcsh clone ssh://<remote>/mr.git
342 cd $XDG_CONFIG_HOME/mr/config.d/
343 ln -s ../available.d/* .
346 mr is used to actually retrieve configs, etc
350 # adapt /usr/share/mr/vcsh to your system if needed
351 include = cat /usr/share/mr/vcsh
352 include = cat $XDG_CONFIG_HOME/mr/config.d/*
353 ~ % echo $XDG_CONFIG_HOME
355 ~ % ls $XDG_CONFIG_HOME/mr/available.d # random selection of my repos
356 git-annex gitk.vcsh git.vcsh ikiwiki mr.vcsh reportbug.vcsh snippets.git wget.vcsh zsh.vcsh
358 # then simply ln -s whatever you want on your local machine from
359 # $XDG_CONFIG_HOME/mr/available.d to $XDG_CONFIG_HOME/mr/config.d
366 ### Keeping repositories Up-to-Date ###
368 This is the beauty of it all. Once you are set up, just run:
375 ### Making Changes ###
377 After you have made some changes, for which you would normally use `git add`
378 and `git commit`, use the vcsh wrapper (like above):
380 vcsh run foo git add -f bar baz quux
381 vcsh run foo git commit
382 vcsh run foo git push
384 By the way, you'll have to use -f/--force flag with git-add because all files
385 will be ignored by default. This is to show you only useful output when running
386 git-status. A fix for this problem is being worked on.
388 ### Using vcsh without mr ###
390 vcsh encourages you to use [mr] [1]. It helps you manage a large number of
391 repositories by running the necessary vcsh commands for you. You may choose not
392 to use mr, in which case you will have to run those commands manually or by
395 #### A Few Examples ####
397 To initialize a new repository: `vcsh init zsh`
399 To clone a repository: `vcsh clone ssh://<remote>/zsh.git`
401 To interact with a repository, use the regular Git commands, but prepend them
402 with `vcsh run $repository_name`. For example:
404 vcsh run zsh git status
405 vcsh run zsh git add -f .zshrc
406 vcsh run zsh git commit
408 Obviously, without mr keeping repositories up-to-date, it will have to be done
409 manually. Alternatively, you could try something like this:
411 for repo in `vcsh list`; do
412 vcsh run $repo git pull;
416 [mr]: http://kitenet.net/~joey/code/mr/
417 [talks]: http://richardhartmann.de/talks/
418 [vcsh]: https://github.com/RichiH/vcsh
419 [vcs-home-list]: http://lists.madduck.net/listinfo/vcs-home