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