]> git.madduck.net Git - code/vcsh.git/blob - README.md

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

README.md: Move Contact section to the end
[code/vcsh.git] / README.md
1 vcsh - Version Control System for $HOME (based on git)
2
3
4 # Index #
5
6 1. [30 second howto](#30-second-howto)
7 2. [Introduction](#introduction)
8 3. [Overview](#overview)
9 4. [Getting Started](#getting-started)
10 5. [Usage](#usage)
11 6. [Contact](#contact)
12
13
14 # 30 second howto #
15
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.
19
20 Let's say you want to version control your `vim` configuration:
21
22     vcsh init vim
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
28
29 If all that looks a _lot_ like standard `git`, that's no coincidence; it's
30 a design feature.
31
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].
35
36
37 # Introduction #
38
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.
50
51 `vcsh` was designed with [mr][mr] in mind so you might want to install that, as
52 well.
53
54 Read `INSTALL.md` and `PACKAGING.md` for instructions specific to your operating
55 system.
56
57 The following overview will try to give you an idea of the use cases and
58 advantages of `vcsh`. See sections 3 and 4 for detailed instructions and
59 examples.
60
61 ## Talks ##
62
63 Some people found it useful to look at slides and videos explaining how `vcsh`
64 works.
65 They can all be found [on the author's talk page][talks].
66
67
68 # Overview
69
70 ## Comparison to Other Solutions ##
71
72 Most people who decide to put their dotfiles under version control start with a
73 single repository in `$HOME`, adding all their dotfiles (and possibly more)
74 to it. This works, of course, but can become a nuisance as soon as you try to
75 manage more than one host.
76
77 The next logical step is to create single-purpose repositories in, for example,
78 `~/.dotfiles` and to create symbolic links into `$HOME`. This gives you the
79 flexibility to check out only certain repositories on different hosts. The
80 downsides of this approach are the necessary manual steps of cloning and
81 symlinking the individual repositories.
82
83 `vcsh` takes this second approach one step further. It expects
84 single-purpose repositories and stores them in a hidden directory (similar
85 to `~/.dotfiles`). However, it does not create symbolic links in `$HOME`; it
86 puts the actual files right into `$HOME`.
87
88 Furthermore, by making use of [mr][mr], it makes it very easy to enable/disable
89 and clone a large number of repositories. The use of `mr` is technically
90 optional (see section 4.3), but it will be an integral part of the proposed
91 system that follows.
92
93 ## Default Directory Layout ##
94
95 To illustrate, this is what a possible directory structure looks like.
96
97     $HOME
98         |-- $XDG_CONFIG_HOME (defaults to $HOME/.config)
99         |   |-- mr
100         |   |   |-- available.d
101         |   |   |   |-- zsh.vcsh
102         |   |   |   |-- gitconfigs.vcsh
103         |   |   |   |-- lftp.vcsh
104         |   |   |   |-- offlineimap.vcsh
105         |   |   |   |-- s3cmd.vcsh
106         |   |   |   |-- tmux.vcsh
107         |   |   |   |-- vim.vcsh
108         |   |   |   |-- vimperator.vcsh
109         |   |   |   `-- snippets.git
110         |   |   `-- config.d
111         |   |       |-- zsh.vcsh        -> ../available.d/zsh.vcsh
112         |   |       |-- gitconfigs.vcsh -> ../available.d/gitconfigs.vcsh
113         |   |       |-- tmux.vcsh       -> ../available.d/tmux.vcsh
114         |   |       `-- vim.vcsh        -> ../available.d/vim.vcsh
115         |   `-- vcsh
116         |       |-- config
117         |       `-- repo.d
118         |           |-- zsh.git  -----------+
119         |           |-- gitconfigs.git      |
120         |           |-- tmux.git            |
121         |           `-- vim.git             |
122         |-- [...]                           |
123         |-- .zshrc   <----------------------+
124         |-- .gitignore.d
125         |   `-- zsh
126         |-- .mrconfig
127         `-- .mrtrust
128
129 ### available.d ###
130
131 The files you see in $XDG\_CONFIG\_HOME/mr/available.d are mr configuration files
132 that contain the commands to manage (checkout, update etc.) a single
133 repository. vcsh repo configs end in .vcsh, git configs end in .git, etc. This
134 is optional and your preference. For example, this is what a zsh.vcsh
135 with read-only access to my zshrc repo looks likes. I.e. in this specific
136 example, push can not work as you will be using the author's repository. This
137 is for demonstration, only. Of course, you are more than welcome to clone from
138 this repository and fork your own.
139
140     [$XDG_CONFIG_HOME/vcsh/repo.d/zsh.git]
141     checkout = vcsh clone 'git://github.com/RichiH/zshrc.git' zsh
142     update   = vcsh run zsh git pull
143     push     = vcsh run zsh git push
144     status   = vcsh run zsh git status
145     gc       = vcsh run zsh git gc
146
147 ### config.d ###
148
149 $XDG\_CONFIG\_HOME/mr/available.d contains *all available* repositories. Only
150 files/links present in mr/config.d, however, will be used by mr. That means
151 that in this example, only the zsh, gitconfigs, tmux and vim repositories will
152 be checked out. A simple `mr update` run in $HOME will clone or update those
153 four repositories listed in config.d.
154
155 ### ~/.mrconfig ###
156
157 Finally, ~/.mrconfig will tie together all those single files which will allow
158 you to conveniently run `mr up` etc. to manage all repositories. It looks like
159 this:
160
161     [DEFAULT]
162     jobs = 5
163     # Use if your mr does not have vcsh support in mainline, yet
164     include = cat /usr/share/mr/vcsh
165     include = cat ${XDG_CONFIG_HOME:-$HOME/.config}/mr/config.d/*
166
167 ### repo.d ###
168
169 $XDG\_CONFIG\_HOME/vcsh/repo.d is the directory where all git repositories which
170 are under vcsh's control are located. Since their working trees are configured
171 to be in $HOME, the files contained in those repositories will be put in $HOME
172 directly.
173 Of course, [mr] [1] will work with this layout if configured according to this
174 document (see above).
175
176 vcsh will check if any file it would want to create exists. If it exists, vcsh
177 will throw a warning and exit. Move away your old config and try again.
178 Optionally, merge your local and your global configs afterwards and push with
179 `vcsh run foo git push`.
180
181 ## Moving into a New Host ##
182
183 To illustrate further, the following steps could move your desired
184 configuration to a new host.
185
186 1. Clone the mr repository (containing available.d, config.d etc.); for
187    example: `vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr`
188 2. Choose your repositories by linking them in config.d (or go with the default
189    you may have already configured by adding symlinks to git).
190 3. Make sure the line 'include = cat /usr/share/mr/vcsh' in .mrconfig points
191    to an existing file
192 4. Run mr to clone the repositories: `cd; mr update`.
193 5. Done.
194
195 Hopefully the above could help explain how this approach saves time by
196
197 1. making it easy to manage, clone and update a large number of repositories
198    (thanks to mr) and
199 2. making it unnecessary to create symbolic links in $HOME (thanks to vcsh).
200
201 If you want to give vcsh a try, follow the instructions below.
202
203
204 # Getting Started #
205
206 Below, you will find a few different methods for setting up vcsh:
207
208 1. The Template Way
209 2. The Steal-from-Template Way
210 3. The Manual Way
211
212 ### The Template Way ###
213
214 #### Prerequisites ####
215
216 Make sure none of the following files and directories exist for your test
217 (user). If they do, move them away for now:
218
219 * ~/.gitignore.d
220 * ~/.mrconfig
221 * $XDG\_CONFIG\_HOME/mr/available.d/mr.vcsh
222 * $XDG\_CONFIG\_HOME/mr/available.d/zsh.vcsh
223 * $XDG\_CONFIG\_HOME/mr/config.d/mr.vcsh
224 * $XDG\_CONFIG\_HOME/vcsh/repo.d/mr.git/
225
226 All of the files are part of the template repository, the directory is where
227 the template will be stored.
228
229     apt-get install mr
230
231 #### Install vcsh ####
232
233 #### Debian ####
234
235 If you are using Debian Squeeze, you will need to enable backports
236
237     apt-get install vcsh
238
239 #### Arch Linux ####
240
241 vcsh is availabe via [AUR](https://aur.archlinux.org/packages.php?ID=54164)
242 and further documentation about the use of AUR is available
243 [on Arch's wiki](https://wiki.archlinux.org/index.php/Arch_User_Repository).
244
245     cd /var/abs/local/
246     wget https://aur.archlinux.org/packages/vc/vcsh-git/vcsh-git.tar.gz
247     tar xfz vcsh-git.tar.gz
248     cd vcsh-git
249     makepkg -s
250     pacman -U vcsh*.pkg.tar.xz
251
252 #### From source ####
253
254 If your version of mr is older than version 1.07, make sure to put
255
256     include = cat /usr/share/mr/vcsh
257
258 into your .mrconfig .
259
260     # choose a location for your checkout
261     cd $HOME
262     mkdir -p ~/work/git
263     git clone git://github.com/RichiH/vcsh.git
264     cd vcsh
265     ln -s vcsh /usr/local/bin                       # or add it to your PATH
266     cd
267
268 #### Clone the Template ####
269
270     vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr
271
272 #### Enable Your Test Repository ####
273
274     mv ~/.zsh   ~/zsh.bak
275     mv ~/.zshrc ~/zshrc.bak
276     cd $XDG_CONFIG_HOME/mr/config.d/
277     ln -s ../available.d/zsh.vcsh .  # link, and thereby enable, the zsh repository
278     cd
279     mr up
280
281 #### Set Up Your Own Repositories ####
282
283 Now, it's time to edit the template config and fill it with your own remotes:
284
285     vim $XDG_CONFIG_HOME/mr/available.d/mr.vcsh
286     vim $XDG_CONFIG_HOME/mr/available.d/zsh.vcsh
287
288 And then create your own stuff:
289
290     vcsh init foo
291     vcsh run foo git add -f bar baz quux
292     vcsh run foo git remote add origin git://quuux
293     vcsh run foo git commit
294     vcsh run foo git push
295
296     cp $XDG_CONFIG_HOME/mr/available.d/mr.vcsh $XDG_CONFIG_HOME/mr/available.d/foo.vcsh
297     vim $XDG_CONFIG_HOME/mr/available.d/foo.vcsh # add your own repo
298
299 Done!
300
301 ### The Steal-from-Template Way ###
302
303 You're welcome to clone the example repository:
304
305     vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr
306     # make sure 'include = cat /usr/share/mr/vcsh' points to an exiting file
307     vim .mrconfig
308
309 Look around in the clone. It should be reasonably simple to understand. If not,
310 poke me, RichiH, on Freenode (query) or OFTC (#vcs-home).
311
312
313 ### The Manual Way ###
314
315 This is how my old setup procedure looked like. Adapt it to your own style or
316 copy mine verbatim, either is fine.
317
318     # Create workspace
319     mkdir -p ~/work/git
320     cd !$
321
322     # Clone vcsh and make it available
323     git clone git://github.com/RichiH/vcsh.git vcsh
324     sudo ln -s ~/work/git/vcsh/vcsh /usr/bin/local
325     hash -r
326
327 Grab my mr config. see below for details on how I set this up
328
329     vcsh clone ssh://<remote>/mr.git
330     cd $XDG_CONFIG_HOME/mr/config.d/
331     ln -s ../available.d/* .
332
333
334 mr is used to actually retrieve configs, etc
335
336     ~ % cat ~/.mrconfig
337     [DEFAULT]
338     # adapt /usr/share/mr/vcsh to your system if needed
339     include = cat /usr/share/mr/vcsh
340     include = cat $XDG_CONFIG_HOME/mr/config.d/*
341     ~ % echo $XDG_CONFIG_HOME
342     /home/richih/.config
343     ~ % ls $XDG_CONFIG_HOME/mr/available.d # random selection of my repos
344     git-annex gitk.vcsh git.vcsh ikiwiki mr.vcsh reportbug.vcsh snippets.git wget.vcsh zsh.vcsh
345     ~ %
346     # then simply ln -s whatever you want on your local machine from
347     # $XDG_CONFIG_HOME/mr/available.d to $XDG_CONFIG_HOME/mr/config.d
348     ~ % cd
349     ~ % mr -j 5 up
350
351
352 # Usage #
353
354 ### Keeping repositories Up-to-Date ###
355
356 This is the beauty of it all. Once you are set up, just run:
357
358     mr up
359     mr push
360
361 Neat.
362
363 ### Making Changes ###
364
365 After you have made some changes, for which you would normally use `git add`
366 and `git commit`, use the vcsh wrapper (like above):
367
368     vcsh run foo git add -f bar baz quux
369     vcsh run foo git commit
370     vcsh run foo git push
371
372 By the way, you'll have to use -f/--force flag with git-add because all files
373 will be ignored by default. This is to show you only useful output when running
374 git-status. A fix for this problem is being worked on.
375
376 ### Using vcsh without mr ###
377
378 vcsh encourages you to use [mr] [1]. It helps you manage a large number of
379 repositories by running the necessary vcsh commands for you. You may choose not
380 to use mr, in which case you will have to run those commands manually or by
381 other means.
382
383 #### A Few Examples ####
384
385 To initialize a new repository: `vcsh init zsh`
386
387 To clone a repository: `vcsh clone ssh://<remote>/zsh.git`
388
389 To interact with a repository, use the regular Git commands, but prepend them
390 with `vcsh run $repository_name`. For example:
391
392     vcsh run zsh git status
393     vcsh run zsh git add -f .zshrc
394     vcsh run zsh git commit
395
396 Obviously, without mr keeping repositories up-to-date, it will have to be done
397 manually. Alternatively, you could try something like this:
398
399     for repo in `vcsh list`; do
400         vcsh run $repo git pull;
401     done
402
403
404 # Contact #
405
406 There are several ways to get in touch with the author and a small but committed
407 community around the general idea of version controlling your (digital) life.
408
409 * IRC: #vcs-home on irc.oftc.net
410
411 * Mailing list: [http://lists.madduck.net/listinfo/vcs-home][vcs-home-list]
412
413 * Pull requests or issues on [https://github.com/RichiH/vcsh][vcsh]
414
415
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