1git-annex-import(1)         General Commands Manual        git-annex-import(1)
2
3
4

NAME

6       git-annex-import - add a tree of files to the repository
7

SYNOPSIS

9       git annex import --from remote branch[:subdir] | [path ...]
10

DESCRIPTION

12       This  command  is  a  way to import a tree of files from elsewhere into
13       your git-annex repository. It can import files from a git-annex special
14       remote, or from a directory.
15

IMPORTING FROM A SPECIAL REMOTE

17       Importing  from  a  special remote first downloads all new content from
18       it, and then constructs a git commit  that  reflects  files  that  have
19       changed  on  the special remote since the last time git-annex looked at
20       it. Merging that commit into your repository will update it to  reflect
21       changes made on the special remote.
22
23       This  way,  something can be using the special remote for file storage,
24       adding files, modifying files, and deleting files, and  you  can  track
25       those changes using git-annex.
26
27       You  can combine using git annex import to fetch changes from a special
28       remote with git annex export to send your local changes to the  special
29       remote.
30
31       You  can  only  import  from  special remotes that were configured with
32       importtree=yes when set  up  with  git-annex-initremote(1).  Only  some
33       kinds  of  special remotes will let you configure them this way. A per‐
34       haps non-exhastive list is the directory, s3, and adb special remotes.
35
36       To import from a special remote, you must specify the name of a branch.
37       A  corresponding  remote  tracking  branch will be updated by git annex
38       import. After that point, it's the same as if you had run a  git  fetch
39       from  a  regular  git  remote; you can merge the changes into your cur‐
40       rently checked out branch.
41
42       For example:
43
44        git annex import master --from myremote
45        git annex merge myremote/master
46
47       You could just as well use git  merge  myremote/master  as  the  second
48       step,  but using git-annex merge avoids a couple of gotchas. When using
49       adjusted branches, it adjusts the branch before merging from it. And it
50       avoids the merge failing on the first merge from an import due to unre‐
51       lated histories.
52
53       If you do use git merge, you can pass  --allow-unrelated-histories  the
54       first  time  you  git merge from an import. Think of this as the remote
55       being a separate git repository with its own files. If  you  first  git
56       annex  export files to a remote, and then git annex import from it, you
57       won't need that option.
58
59       You can import into a subdirectory, using the  "branch:subdir"  syntax.
60       For  example,  if  "camera" is a special remote that accesses a camera,
61       and you want to import those into the photos directory, rather than  to
62       the root of your repository:
63
64        git annex import master:photos --from camera
65        git merge camera/master
66
67       The  git annex sync --content command (and the git-annex assistant) can
68       also be used to import from a special remote.  To do this, you need  to
69       configure  "remote.<name>.annex-tracking-branch" to tell it what branch
70       to track. For example:
71
72        git config remote.myremote.annex-tracking-branch master
73        git annex sync --content
74
75       If a preferred content expression is configured for the special remote,
76       it will be honored when importing from it. Files that are not preferred
77       content of the remote will not be imported from it, but will be left on
78       the remote.
79
80       However,  preferred content expressions that relate to the key can't be
81       matched when importing, because the content of the file is  not  known.
82       Importing  will  fail  when such a preferred content expression is set.
83       This includes expressions containing "copies=", "metadata=", and  other
84       things that depend on the key. Preferred content expressions containing
85       "include=", "exclude=" "smallerthan=", "largerthan=" will work.
86

IMPORTING FROM A DIRECTORY

88       When run with a path, git annex import moves files from somewhere  out‐
89       side the git working copy, and adds them to the annex.
90
91       This  is a legacy interface. It is still supported, but please consider
92       switching to importing from a directory special remote  instead,  using
93       the interface documented above.
94
95       Individual  files  to import can be specified. If a directory is speci‐
96       fied, the entire directory is imported.
97
98        git annex import /media/camera/DCIM/*
99
100       When importing files, there's a possibility of importing a duplicate of
101       a  file  that  is  already  known to git-annex -- its content is either
102       present in the local repository already, or git-annex knows of  another
103       repository  that contains it, or it was present in the annex before but
104       has been removed now.
105
106       By default, importing a duplicate of a known file will result in a  new
107       filename  being  added  to  the  repository,  so  the duplicate file is
108       present in the  repository  twice.  (With  all  checksumming  backends,
109       including  the  default  SHA256E,  only  one  copy  of the data will be
110       stored.)
111
112       Several options can be used to adjust handling of duplicate files,  see
113       --duplicate,  --deduplicate, --skip-duplicates, --clean-duplicates, and
114       --reinject-duplicates documentation below.
115

OPTIONS FOR IMPORTING FROM A DIRECTORY

117       --duplicate
118
119              Do not delete files from the import location.
120
121              Running with this option repeatedly can import  the  same  files
122              into different git repositories, or branches, or different loca‐
123              tions in a git repository.
124
125       --deduplicate
126              Only import files that are not duplicates; duplicate files  will
127              be deleted from the import location.
128
129       --skip-duplicates
130              Only  import  files that are not duplicates. Avoids deleting any
131              files from the import location.
132
133       --clean-duplicates
134              Does not import any files, but any files  found  in  the  import
135              location that are duplicates are deleted.
136
137       --reinject-duplicates
138              Imports files that are not duplicates. Files that are duplicates
139              have their content reinjected into the annex  (similar  to  git-
140              annex-reinject(1)).
141
142       --force
143              Allow existing files to be overwritten by newly imported files.
144
145              Also, causes .gitignore to not take effect when adding files.
146
147       file matching options
148              Many of the git-annex-matching-options(1) can be used to specify
149              files to import.
150
151                   git annex import /dir --include='*.png'
152
153              ## COMMON OPTIONS
154
155       --jobs=N -JN
156              Imports multiple files in parallel. This  may  be  faster.   For
157              example: -J4
158
159              Setting this to "cpus" will run one job per CPU core.
160
161       --json Enable  JSON  output.  This is intended to be parsed by programs
162              that use git-annex. Each line of output is a JSON object.
163
164       --json-error-messages
165              Messages that would normally be output  to  standard  error  are
166              included in the json instead.
167

CAVEATS

169       Note that using --deduplicate or --clean-duplicates with the WORM back‐
170       end does not look at file content, but filename and mtime.
171
172       If annex.largefiles is configured, and does not match a file, git annex
173       import  will  add  the  non-large  file directly to the git repository,
174       instead of to the annex.
175

SEE ALSO

177       git-annex(1)
178
179       git-annex-add(1)
180
181       git-annex-export(1)
182
183       git-annex-preferred-content(1)
184

AUTHOR

186       Joey Hess <id@joeyh.name>
187
188                                                           git-annex-import(1)
Impressum