aboutsummaryrefslogtreecommitdiff
path: root/doc/git-annex.mdwn
blob: 59da9dd8cf9ada1218c5dbff3afcf07f2e5b272a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# NAME

git-annex - manage files with git, without checking their contents in

# SYNOPSIS

git annex command [params ...]

# DESCRIPTION

git-annex allows managing files with git, without checking the file
contents into git. While that may seem paradoxical, it is useful when
dealing with files larger than git can currently easily handle, whether due
to limitations in memory, checksumming time, or disk space.

Even without file content tracking, being able to manage files with git,
move files around and delete files with versioned directory trees, and use
branches and distributed clones, are all very handy reasons to use git. And
annexed files can co-exist in the same git repository with regularly
versioned files, which is convenient for maintaining documents, Makefiles,
etc that are associated with annexed files but that benefit from full
revision control.

When a file is annexed, its content is moved into a key-value store, and
a symlink is made that points to the content. These symlinks are checked into
git and versioned like regular files. You can move them around, delete 
them, and so on. Pushing to another git repository will make git-annex
there aware of the annexed file, and it can be used to retrieve its
content from the key-value store.

# EXAMPLES

	# git annex get video/hackity_hack_and_kaxxt.mov
	get video/_why_hackity_hack_and_kaxxt.mov (not available)
	  I was unable to access these remotes: server
	  Try making some of these repositories available:
	  	5863d8c0-d9a9-11df-adb2-af51e6559a49  -- my home file server
	   	58d84e8a-d9ae-11df-a1aa-ab9aa8c00826  -- portable USB drive
	   	ca20064c-dbb5-11df-b2fe-002170d25c55  -- backup SATA drive
	failed
	# sudo mount /media/usb
	# git remote add usbdrive /media/usb
	# git annex get video/hackity_hack_and_kaxxt.mov
	get video/hackity_hack_and_kaxxt.mov (from usbdrive...) ok
	
	# git annex add iso
	add iso/Debian_5.0.iso ok
	
	# git annex drop iso/Debian_4.0.iso
	drop iso/Debian_4.0.iso ok
	
	# git annex move iso --to=usbdrive
	move iso/Debian_5.0.iso (moving to usbdrive...) ok

# COMMONLY USED COMMANDS

Like many git commands, git-annex can be passed a path that 
is either a file or a directory. In the latter case it acts on all relevant
files in the directory. When no path is specified, most git-annex commands
default to acting on all relevant files in the current directory (and
subdirectories).

* add [path ...]

  Adds files in the path to the annex. Files that are already checked into
  git, or that git has been configured to ignore will be silently skipped.

* get [path ...]

  Makes the content of annexed files available in this repository. This
  will involve copying them from another repository, or downloading them,
  or transferring them from some kind of key-value store.

* drop [path ...]

  Drops the content of annexed files from this repository. 

  git-annex will refuse to drop content if it cannot verify it is
  safe to do so. At least one copy of content needs to exist in another
  remote. This can be overridden with the --force switch.

* move [path ...]
  
  When used with the --from option, moves the content of annexed files
  from the specified repository to the current one.

  When used with the --to option, moves the content of annexed files from
  the current repository to the specified one.

* copy [path ...]

  When used with the --from option, copies the content of annexed files
  from the specified repository to the current one.

  When used with the --to option, copies the content of annexed files from
  the current repository to the specified one.

  To avoid contacting the remote to check if it has every file, specify --fast

* unlock [path ...]

  Normally, the content of annexed files is protected from being changed.
  Unlocking a annexed file allows it to be modified. This replaces the
  symlink for each specified file with a copy of the file's content.
  You can then modify it and `git annex add` (or `git commit`) to inject
  it back into the annex.

* edit [path ...]

  This is an alias for the unlock command. May be easier to remember,
  if you think of this as allowing you to edit an annexed file.

* lock [path ...]

  Use this to undo an unlock command if you don't want to modify
  the files, or have made modifications you want to discard.

* addurl [url ...]

  Downloads each url to a file, which is added to the annex.

  To avoid immediately downloading the url, specify --fast

# REPOSITORY SETUP COMMANDS

* init [description]

  Until a repository (or one of its remotes) has been initialized,
  git-annex will refuse to operate on it, to avoid accidentially
  using it in a repository that was not intended to have an annex.

  It's useful, but not mandatory, to initialize each new clone
  of a repository with its own description.

* describe repository description

  Changes the description of a repository.

  The repository to describe can be specified by git remote name or
  by uuid. To change the description of the current repository, use
  "."

* initremote name [param=value ...]

  Sets up a special remote. The remote's
  configuration is specified by the parameters. If a remote
  with the specified name has already been configured, its configuration
  is modified by any values specified. In either case, the remote will be
  added to `.git/config`.

  Example Amazon S3 remote:

	initremote mys3 type=S3 encryption=none datacenter=EU

* trust [repository ...]

  Records that a repository is trusted to not unexpectedly lose
  content. Use with care.

  To trust the current repository, use "."

* untrust [repository ...]

  Records that a repository is not trusted and could lose content
  at any time.

* semitrust [repository ...]

  Returns a repository to the default semi trusted state.

# REPOSITORY MAINTENANCE COMMANDS

* fsck [path ...]

  With no parameters, this command checks the whole annex for consistency,
  and warns about or fixes any problems found.

  With parameters, only the specified files are checked.

  To avoid expensive checksum calculations, specify --fast

* unused

  Checks the annex for data that does not correspond to any files present
  in the currently checked out branch, and prints a numbered list of the data.

  To only show unused temp and bad files, specify --fast

  To check data on a remote that does not correspond to any files present
  on the locally checked out branch, specify --from.

* dropunused [number ...]

  Drops the data corresponding to the numbers, as listed by the last
  `git annex unused`

  To drop the data from a remote, specify --from.

* merge

  Automatically merges any changes from remotes into the git-annex branch.
  While git-annex mostly handles keeping the git-annex branch merged
  automatically, if you find you are unable to push the git-annex branch
  due non-fast-forward, this will fix it.

* fix [path ...]

  Fixes up symlinks that have become broken to again point to annexed content.
  This is useful to run if you have been moving the symlinks around,
  but is done automatically when committing a change with git too.

* upgrade

  Upgrades the repository to current layout.

# QUERY COMMANDS

* version

  Shows the version of git-annex, as well as repository version information.

* find [path ...]

  Outputs a list of annexed files whose content is currently present.
  Or, if a file matching option is specified, outputs a list of all
  matching files, whether or not their content is currently present.

  With no parameters, defaults to finding all files in the current directory
  and its subdirectories.

* whereis [path ...]

  Displays a list of repositories known to contain the content of the
  specified file or files.

* status

  Displays some statistics and other information, including how much data
  is in the annex.

* map

  Helps you keep track of your repositories, and the connections between them,
  by going out and looking at all the ones it can get to, and generating a
  Graphviz file displaying it all. If the `dot` command is available, it is
  used to display the file to your screen (using x11 backend).

  Note that this only connects to hosts that the host it's run on can
  directly connect to. It does not try to tunnel through intermediate hosts.
  So it might not show all connections between the repositories in the network.

  Also, if connecting to a host requires a password, you might have to enter
  it several times as the map is being built.

  Note that this subcommand can be used to graph any git repository; it
  is not limited to git-annex repositories.

# UTILITY COMMANDS

* migrate [path ...]

  Changes the specified annexed files to use the default key-value backend
  (or the one specified with --backend). Only files whose content
  is currently available are migrated.

  Note that the content is also still available using the old key after
  migration. Use `git annex unused` to find and remove the old key.

  Normally, nothing will be done to files already using the new backend.
  However, if a backend changes the information it uses to construct a key,
  this can also be used to migrate files to use the new key format.

* unannex [path ...]

  Use this to undo an accidental `git annex add` command. You can use
  `git annex unannex` to move content out of the annex at any point,
  even if you've already committed it.

  This is not the command you should use if you intentionally annexed a
  file and don't want its contents any more. In that case you should use
  `git annex drop` instead, and you can also `git rm` the file.

  In --fast mode, this command leaves content in the annex, simply making
  a hard link to it.

* uninit

  Use this to stop using git annex. It will unannex every file in the
  repository, and remove all of git-annex's other data, leaving you with a
  git repository plus the previously annexed files.

# PLUMBING COMMANDS

* pre-commit [path ...]

  Fixes up symlinks that are staged as part of a commit, to ensure they
  point to annexed content. Also handles injecting changes to unlocked
  files into the annex.

  This is meant to be called from git's pre-commit hook. `git annex init`
  automatically creates a pre-commit hook using this.

* fromkey file

  This plumbing-level command can be used to manually set up a file
  in the git repository to link to a specified key.

* dropkey [key ...]

  This plumbing-level command drops the annexed data for the specified
  keys from this repository.

  This can be used to drop content for arbitrary keys, which do not need
  to have a file in the git repository pointing at them.

  Example:

	git annex dropkey SHA1-s10-7da006579dd64330eb2456001fd01948430572f2

* setkey file

  This plumbing-level command sets the annexed data for a key to the
  content of the specified file, and then removes the file.

  Example:

	git annex setkey --key=WORM-s3-m1287765018--file /tmp/file

# OPTIONS

* --force

  Force unsafe actions, such as dropping a file's content when no other
  source of it can be verified to still exist, or adding ignored files.
  Use with care.

* --fast

  Enables less expensive, but also less thorough versions of some commands.
  What is avoided depends on the command.

* --auto

  Enables automatic mode. Commands that get, drop, or move file contents
  will only do so when needed to help satisfy the setting of annex.numcopies.

* --quiet

  Avoid the default verbose display of what is done; only show errors
  and progress displays.

* --verbose

  Enable verbose display.

* --json

  Rather than the normal output, generate JSON. This is intended to be
  parsed by programs that use git-annex. Each line of output is a JSON
  object.

* --debug

  Show debug messages.

* --from=repository

  Specifies a repository that content will be retrieved from, or that
  should otherwise be acted on.

  It should be specified using the name of a configured remote.

* --to=repository

  Specifies a repository that content will be sent to.

  It should be specified using the name of a configured remote.

* --numcopies=n

  Overrides the `annex.numcopies` setting, forcing git-annex to ensure the
  specified number of copies exist.

* --trust=repository
* --semitrust=repository
* --untrust=repository

  Overrides trust settings for a repository. May be specified more than once.
  
  The repository should be specified using the name of a configured remote,
  or the UUID or description of a repository.

* --backend=name

  Specifies which key-value backend to use. This can be used when
  adding a file to the annex, or migrating a file. Once files
  are in the annex, their backend is known and this option is not
  necessary.

* --key=name

  Specifies a key to operate on.

* -c name=value

  Used to override git configuration settings. May be specified multiple times.

# FILE MATCHING OPTIONS

These options can all be specified multiple times, and can be combined to
limit which files git-annex acts on.

Arbitrarily complicated expressions can be built using these options.
For example:

	--exclude '*.mp3' --and --not -( --in usbdrive --or --in archive -)

The above example prevents git-annex from working on mp3 files whose
file contents are present at either of two repositories.

* --exclude=glob

  Skips files matching the glob pattern. The glob is matched relative to
  the current directory. For example: --exclude='*.mp3' --exclude='subdir/*'

* --in=repository

  Matches only files that git-annex believes have their contents present
  in a repository.

  The repository should be specified using the name of a configured remote,
  or the UUID or description of a repository. For the current repository,
  use "--in=."

* --copies=number

  Matches only files that git-annex believes to have the specified number
  of copies.

* --not

  Inverts the next file matching option. For example, to only act on
  mp3s, use: --not --exclude='*.mp3'

* --and

  Requires that both the previous and the next file matching option matches.
  The default.

* --or

  Requires that either the previous, or the next file matching option matches.

* -(

  Opens a group of file matching options.

* -)

  Closes a group of file matching options.

# CONFIGURATION

Like other git commands, git-annex is configured via `.git/config`.
Here are all the supported configuration settings.

* `annex.uuid`

  A unique UUID for this repository (automatically set).

* `annex.numcopies`

  Number of copies of files to keep across all repositories. (default: 1)

* `annex.backends`

  Space-separated list of names of the key-value backends to use. 
  The first listed is used to store new files by default. 

* `remote.<name>.annex-cost`

  When determining which repository to
  transfer annexed files from or to, ones with lower costs are preferred.
  The default cost is 100 for local repositories, and 200 for remote
  repositories.

* `remote.<name>.annex-cost-command`

  If set, the command is run, and the number it outputs is used as the cost.
  This allows varying the cost based on eg, the current network. The
  cost-command can be any shell command line.

* `remote.<name>.annex-ignore`

  If set to `true`, prevents git-annex
  from using this remote by default. (You can still request it be used
  by the --from and --to options.)

  This is, for example, useful if the remote is located somewhere
  without git-annex-shell. (For example, if it's on GitHub).
  Or, it could be used if the network connection between two
  repositories is too slow to be used normally.

* `remote.<name>.annex-uuid`

  git-annex caches UUIDs of remote repositories here.

* `remote.<name>.annex-ssh-options`

  Options to use when using ssh to talk to this remote.

* `remote.<name>.annex-rsync-options`

  Options to use when using rsync
  to or from this remote. For example, to force ipv6, and limit
  the bandwidth to 100Kbyte/s, set it to "-6 --bwlimit 100"

* `remote.<name>.annex-bup-split-options`

  Options to pass to bup split when storing content in this remote.
  For example, to limit the bandwidth to 100Kbye/s, set it to "--bwlimit 100k"
  (There is no corresponding option for bup join.)

* `annex.ssh-options`, `annex.rsync-options`, `annex.bup-split-options`

  Default ssh, rsync, and bup options to use if a remote does not have
  specific options.

* `annex.diskreserve`

  Amount of disk space to reserve. Disk space is checked when transferring
  content to avoid running out, and additional free space can be reserved
  via this option, to make space for more important content (such as git
  commit logs). Can be specified with any commonly used units, for example,
  "0.5 gb" or "100 KiloBytes"

  The default reserve is 1 megabyte.

* `annex.version`

  Automatically maintained, and used to automate upgrades between versions.

* `remote.<name>.buprepo`

  Used by bup special remotes, this configures
  the location of the bup repository to use. Normally this is automaticaly
  set up by `git annex initremote`, but you can change it if needed.

* `remote.<name>.directory`

  Used by directory special remotes, this configures
  the location of the directory where annexed files are stored for this
  remote. Normally this is automaticaly set up by `git annex initremote`,
  but you can change it if needed.

* `remote.<name>.s3`

  Used to identify Amazon S3 special remotes.
  Normally this is automaticaly set up by `git annex initremote`.

# CONFIGURATION VIA .gitattributes

The key-value backend used when adding a new file to the annex can be
configured on a per-file-type basis via `.gitattributes` files. In the file,
the `annex.backend` attribute can be set to the name of the backend to
use. For example, this here's how to use the WORM backend by default,
but the SHA1 backend for ogg files:

	* annex.backend=WORM
	*.ogg annex.backend=SHA1

The numcopies setting can also be configured on a per-file-type basis via
the `annex.numcopies` attribute in `.gitattributes` files.
For example, this makes two copies be needed for wav files:

	*.wav annex.numcopies=2

# FILES

These files are used by git-annex, in your git repository:

`.git/annex/objects/` contains the annexed file contents that are currently
available. Annexed files in your git repository symlink to that content.

# SEE ALSO

Most of git-annex's documentation is available on its web site, 
<http://git-annex.branchable.com/>

If git-annex is installed from a package, a copy of its documentation
should be included, in, for example, `/usr/share/doc/git-annex/`

# AUTHOR

Joey Hess <joey@kitenet.net>

<http://git-annex.branchable.com/>

Warning: this page is automatically made into a man page via [mdwn2man](http://git.ikiwiki.info/?p=ikiwiki;a=blob;f=mdwn2man;hb=HEAD).  Edit with care