]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-svn.txt
Merge branch 'maint'
[thirdparty/git.git] / Documentation / git-svn.txt
CommitLineData
3397f9df
EW
1git-svn(1)
2==========
3
4NAME
5----
c3f0baac 6git-svn - Bidirectional operation between a single Subversion branch and git
3397f9df
EW
7
8SYNOPSIS
9--------
10'git-svn' <command> [options] [arguments]
11
12DESCRIPTION
13-----------
0d313b2b
EW
14git-svn is a simple conduit for changesets between Subversion and git.
15It is not to be confused with gitlink:git-svnimport[1], which is
a836a0e1 16read-only.
3397f9df 17
0d313b2b 18git-svn was originally designed for an individual developer who wants a
3397f9df 19bidirectional flow of changesets between a single branch in Subversion
0d313b2b
EW
20and an arbitrary number of branches in git. Since its inception,
21git-svn has gained the ability to track multiple branches in a manner
a836a0e1 22similar to git-svnimport.
3397f9df 23
0d313b2b
EW
24git-svn is especially useful when it comes to tracking repositories
25not organized in the way Subversion developers recommend (trunk,
26branches, tags directories).
3397f9df
EW
27
28COMMANDS
29--------
0ea4d4c9
JF
30--
31
32'init'::
a836a0e1
EW
33 Initializes an empty git repository with additional
34 metadata directories for git-svn. The Subversion URL
35 may be specified as a command-line argument, or as full
36 URL arguments to -T/-t/-b. Optionally, the target
37 directory to operate on can be specified as a second
38 argument. Normally this command initializes the current
39 directory.
3397f9df 40
cc1793e2
KW
41-T<trunk_subdir>;;
42--trunk=<trunk_subdir>;;
43-t<tags_subdir>;;
44--tags=<tags_subdir>;;
45-b<branches_subdir>;;
46--branches=<branches_subdir>;;
a836a0e1
EW
47 These are optional command-line options for init. Each of
48 these flags can point to a relative repository path
49 (--tags=project/tags') or a full url
50 (--tags=https://foo.org/project/tags)
cc1793e2 51--no-metadata;;
0dfaf0a4 52 Set the 'noMetadata' option in the [svn-remote] config.
cc1793e2 53--use-svm-props;;
0dfaf0a4 54 Set the 'useSvmProps' option in the [svn-remote] config.
cc1793e2 55--use-svnsync-props;;
0dfaf0a4 56 Set the 'useSvnsyncProps' option in the [svn-remote] config.
cc1793e2 57--rewrite-root=<URL>;;
0dfaf0a4 58 Set the 'rewriteRoot' option in the [svn-remote] config.
cc1793e2 59--username=<USER>;;
a0d7fe3f
SV
60 For transports that SVN handles authentication for (http,
61 https, and plain svn), specify the username. For other
62 transports (eg svn+ssh://), you must include the username in
63 the URL, eg svn+ssh://foo@svn.bar.com/project
cc1793e2 64--prefix=<prefix>;;
a836a0e1
EW
65 This allows one to specify a prefix which is prepended
66 to the names of remotes if trunk/branches/tags are
67 specified. The prefix does not automatically include a
68 trailing slash, so be sure you include one in the
0d351e9c
GP
69 argument if that is what you want. If --branches/-b is
70 specified, the prefix must include a trailing slash.
71 Setting a prefix is useful if you wish to track multiple
72 projects that share a common repository.
81c5a0e6 73
a836a0e1 74'fetch'::
a836a0e1
EW
75 Fetch unfetched revisions from the Subversion remote we are
76 tracking. The name of the [svn-remote "..."] section in the
77 .git/config file may be specified as an optional command-line
78 argument.
b705ba43 79
a81ed0b6
EW
80'clone'::
81 Runs 'init' and 'fetch'. It will automatically create a
82 directory based on the basename of the URL passed to it;
83 or if a second argument is passed; it will create a directory
84 and work within that. It accepts all arguments that the
85 'init' and 'fetch' commands accept; with the exception of
86 '--fetch-all'. After a repository is cloned, the 'fetch'
87 command will be able to update revisions without affecting
88 the working tree; and the 'rebase' command will be able
89 to update the working tree with the latest changes.
90
91'rebase'::
92 This fetches revisions from the SVN parent of the current HEAD
93 and rebases the current (uncommitted to SVN) work against it.
94
112f6385
SV
95This works similarly to 'svn update' or 'git-pull' except that
96it preserves linear history with 'git-rebase' instead of
97'git-merge' for ease of dcommit-ing with git-svn.
a81ed0b6 98
112f6385
SV
99This accepts all options that 'git-svn fetch' and 'git-rebase'
100accepts. However '--fetch-all' only fetches from the current
101[svn-remote], and not all [svn-remote] definitions.
a81ed0b6 102
112f6385
SV
103Like 'git-rebase'; this requires that the working tree be clean
104and have no uncommitted changes.
cc1793e2 105
dee41f3e
EW
106-l;;
107--local;;
108 Do not fetch remotely; only run 'git-rebase' against the
109 last fetched commit from the upstream SVN.
a81ed0b6 110
b22d4497 111'dcommit'::
2eff1425 112 Commit each diff from a specified head directly to the SVN
b22d4497 113 repository, and then rebase or reset (depending on whether or
2eff1425
EW
114 not there is a diff between SVN and head). This will create
115 a revision in SVN for each commit in git.
116 It is recommended that you run git-svn fetch and rebase (not
117 pull or merge) your commits against the latest changes in the
118 SVN repository.
dd31da2f
EW
119 An optional command-line argument may be specified as an
120 alternative to HEAD.
3289e86e 121 This is advantageous over 'set-tree' (below) because it produces
b22d4497 122 cleaner, more linear history.
171af110
KW
123+
124--no-rebase;;
125 After committing, do not rebase or reset.
112f6385 126--
b22d4497 127
e8f5d908
EW
128'log'::
129 This should make it easy to look up svn log messages when svn
130 users refer to -r/--revision numbers.
112f6385
SV
131+
132The following features from `svn log' are supported:
133+
134--
135--revision=<n>[:<n>];;
136 is supported, non-numeric args are not:
137 HEAD, NEXT, BASE, PREV, etc ...
138-v/--verbose;;
139 it's not completely compatible with the --verbose
140 output in svn log, but reasonably close.
141--limit=<n>;;
142 is NOT the same as --max-count, doesn't count
143 merged/excluded commits
144--incremental;;
145 supported
146--
147+
148New features:
149+
150--
151--show-commit;;
152 shows the git commit sha1, as well
153--oneline;;
154 our version of --pretty=oneline
155--
156+
157Any other arguments are passed directly to `git log'
e8f5d908 158
112f6385 159--
26e60160
AR
160'find-rev'::
161 When given an SVN revision number of the form 'rN', returns the
b3cb7e45
AR
162 corresponding git commit hash (this can optionally be followed by a
163 tree-ish to specify which branch should be searched). When given a
164 tree-ish, returns the corresponding SVN revision number.
26e60160 165
3289e86e 166'set-tree'::
e8f5d908 167 You should consider using 'dcommit' instead of this command.
3397f9df
EW
168 Commit specified commit or tree objects to SVN. This relies on
169 your imported fetch data being up-to-date. This makes
170 absolutely no attempts to do patching when committing to SVN, it
171 simply overwrites files with those specified in the tree or
172 commit. All merging is assumed to have taken place
173 independently of git-svn functions.
174
0ea4d4c9 175'show-ignore'::
8f22562c
EW
176 Recursively finds and lists the svn:ignore property on
177 directories. The output is suitable for appending to
178 the $GIT_DIR/info/exclude file.
179
e8f5d908
EW
180'commit-diff'::
181 Commits the diff of two tree-ish arguments from the
23bfbb81 182 command-line. This command is intended for interoperability with
e8f5d908
EW
183 git-svnimport and does not rely on being inside an git-svn
184 init-ed repository. This command takes three arguments, (a) the
185 original tree to diff against, (b) the new tree result, (c) the
186 URL of the target Subversion repository. The final argument
187 (URL) may be omitted if you are working from a git-svn-aware
188 repository (that has been init-ed with git-svn).
45bf473a 189 The -r<revision> option is required for this.
e8f5d908 190
0ea4d4c9
JF
191--
192
3397f9df
EW
193OPTIONS
194-------
0ea4d4c9
JF
195--
196
a836a0e1 197--shared[={false|true|umask|group|all|world|everybody}]::
e8f5d908
EW
198--template=<template_directory>::
199 Only used with the 'init' command.
5c94f87e 200 These are passed directly to gitlink:git-init[1].
e8f5d908 201
3397f9df
EW
202-r <ARG>::
203--revision <ARG>::
3397f9df 204
a836a0e1 205Used with the 'fetch' command.
0ea4d4c9 206
a836a0e1
EW
207This allows revision ranges for partial/cauterized history
208to be supported. $NUMBER, $NUMBER1:$NUMBER2 (numeric ranges),
209$NUMBER:HEAD, and BASE:$NUMBER are all supported.
3397f9df 210
a836a0e1
EW
211This can allow you to make partial mirrors when running fetch;
212but is generally not recommended because history will be skipped
213and lost.
3397f9df
EW
214
215-::
216--stdin::
3397f9df 217
3289e86e 218Only used with the 'set-tree' command.
0ea4d4c9
JF
219
220Read a list of commits from stdin and commit them in reverse
221order. Only the leading sha1 is read from each line, so
222git-rev-list --pretty=oneline output can be used.
3397f9df
EW
223
224--rmdir::
3397f9df 225
3289e86e 226Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
0ea4d4c9
JF
227
228Remove directories from the SVN tree if there are no files left
229behind. SVN can version empty directories, and they are not
230removed by default if there are no files left in them. git
231cannot version empty directories. Enabling this flag will make
232the commit to SVN act like git.
3397f9df 233
e0d10e1c 234config key: svn.rmdir
20b1d700 235
3397f9df
EW
236-e::
237--edit::
3397f9df 238
3289e86e 239Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
3397f9df 240
0ea4d4c9
JF
241Edit the commit message before committing to SVN. This is off by
242default for objects that are commits, and forced on when committing
243tree objects.
244
e0d10e1c 245config key: svn.edit
20b1d700 246
72942938
EW
247-l<num>::
248--find-copies-harder::
72942938 249
3289e86e 250Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
0ea4d4c9
JF
251
252They are both passed directly to git-diff-tree see
253gitlink:git-diff-tree[1] for more information.
72942938 254
0ea4d4c9 255[verse]
e0d10e1c
TP
256config key: svn.l
257config key: svn.findcopiesharder
20b1d700 258
81c5a0e6
EW
259-A<filename>::
260--authors-file=<filename>::
261
0ea4d4c9
JF
262Syntax is compatible with the files used by git-svnimport and
263git-cvsimport:
81c5a0e6
EW
264
265------------------------------------------------------------------------
0ea4d4c9 266 loginname = Joe User <user@example.com>
81c5a0e6
EW
267------------------------------------------------------------------------
268
0ea4d4c9
JF
269If this option is specified and git-svn encounters an SVN
270committer name that does not exist in the authors-file, git-svn
271will abort operation. The user will then have to add the
272appropriate entry. Re-running the previous git-svn command
273after the authors-file is modified should continue operation.
81c5a0e6 274
e0d10e1c 275config key: svn.authorsfile
e8f5d908
EW
276
277-q::
278--quiet::
cec21ca7 279 Make git-svn less verbose.
e8f5d908
EW
280
281--repack[=<n>]::
112f6385
SV
282--repack-flags=<flags>::
283
284These should help keep disk usage sane for large fetches
285with many revisions.
e8f5d908 286
112f6385
SV
287--repack takes an optional argument for the number of revisions
288to fetch before repacking. This defaults to repacking every
2891000 commits fetched if no argument is specified.
e8f5d908 290
112f6385 291--repack-flags are passed directly to gitlink:git-repack[1].
e8f5d908 292
112f6385 293[verse]
e0d10e1c
TP
294config key: svn.repack
295config key: svn.repackflags
0ea4d4c9 296
b22d4497
EW
297-m::
298--merge::
299-s<strategy>::
300--strategy=<strategy>::
301
a81ed0b6 302These are only used with the 'dcommit' and 'rebase' commands.
b22d4497
EW
303
304Passed directly to git-rebase when using 'dcommit' if a
305'git-reset' cannot be used (see dcommit).
306
307-n::
308--dry-run::
309
310This is only used with the 'dcommit' command.
311
312Print out the series of git arguments that would show
313which diffs would be committed to SVN.
314
0ea4d4c9 315--
81c5a0e6 316
448c81b4
EW
317ADVANCED OPTIONS
318----------------
0ea4d4c9
JF
319--
320
448c81b4
EW
321-i<GIT_SVN_ID>::
322--id <GIT_SVN_ID>::
0ea4d4c9 323
a836a0e1
EW
324This sets GIT_SVN_ID (instead of using the environment). This
325allows the user to override the default refname to fetch from
326when tracking a single URL. The 'log' and 'dcommit' commands
327no longer require this switch as an argument.
0ea4d4c9 328
9760adcc
EW
329-R<remote name>::
330--svn-remote <remote name>::
331 Specify the [svn-remote "<remote name>"] section to use,
a836a0e1
EW
332 this allows SVN multiple repositories to be tracked.
333 Default: "svn"
9760adcc 334
e8f5d908
EW
335--follow-parent::
336 This is especially helpful when we're tracking a directory
337 that has been moved around within the repository, or if we
338 started tracking a branch and never tracked the trunk it was
0bed5eaa
EW
339 descended from. This feature is enabled by default, use
340 --no-follow-parent to disable it.
e8f5d908 341
e0d10e1c 342config key: svn.followparent
e8f5d908 343
a81ed0b6
EW
344--
345CONFIG FILE-ONLY OPTIONS
346------------------------
347--
348
0dfaf0a4
EW
349svn.noMetadata::
350svn-remote.<name>.noMetadata::
e8f5d908 351
112f6385
SV
352This gets rid of the git-svn-id: lines at the end of every commit.
353
354If you lose your .git/svn/git-svn/.rev_db file, git-svn will not
355be able to rebuild it and you won't be able to fetch again,
356either. This is fine for one-shot imports.
e8f5d908 357
112f6385
SV
358The 'git-svn log' command will not work on repositories using
359this, either. Using this conflicts with the 'useSvmProps'
360option for (hopefully) obvious reasons.
97ae0911 361
0dfaf0a4
EW
362svn.useSvmProps::
363svn-remote.<name>.useSvmProps::
97ae0911 364
112f6385
SV
365This allows git-svn to re-map repository URLs and UUIDs from
366mirrors created using SVN::Mirror (or svk) for metadata.
367
368If an SVN revision has a property, "svm:headrev", it is likely
369that the revision was created by SVN::Mirror (also used by SVK).
370The property contains a repository UUID and a revision. We want
371to make it look like we are mirroring the original URL, so
372introduce a helper function that returns the original identity
373URL and UUID, and use it when generating metadata in commit
374messages.
97ae0911 375
0dfaf0a4
EW
376svn.useSvnsyncProps::
377svn-remote.<name>.useSvnsyncprops::
a81ed0b6
EW
378 Similar to the useSvmProps option; this is for users
379 of the svnsync(1) command distributed with SVN 1.4.x and
380 later.
381
0dfaf0a4 382svn-remote.<name>.rewriteRoot::
a81ed0b6
EW
383 This allows users to create repositories from alternate
384 URLs. For example, an administrator could run git-svn on the
385 server locally (accessing via file://) but wish to distribute
386 the repository with a public http:// or svn:// URL in the
387 metadata so users of it will see the public URL.
388
a81ed0b6
EW
389Since the noMetadata, rewriteRoot, useSvnsyncProps and useSvmProps
390options all affect the metadata generated and used by git-svn; they
391*must* be set in the configuration file before any history is imported
392and these settings should never be changed once they are set.
393
394Additionally, only one of these four options can be used per-svn-remote
395section because they affect the 'git-svn-id:' metadata line.
e8f5d908 396
0ea4d4c9 397--
448c81b4 398
112f6385
SV
399BASIC EXAMPLES
400--------------
3397f9df 401
0d313b2b 402Tracking and contributing to a the trunk of a Subversion-managed project:
3397f9df 403
20b1d700 404------------------------------------------------------------------------
a81ed0b6
EW
405# Clone a repo (like git clone):
406 git-svn clone http://svn.foo.org/project/trunk
407# Enter the newly cloned directory:
408 cd trunk
409# You should be on master branch, double-check with git-branch
410 git branch
411# Do some work and commit locally to git:
412 git commit ...
413# Something is committed to SVN, rebase your local changes against the
414# latest changes in SVN:
415 git-svn rebase
416# Now commit your changes (that were committed previously using git) to SVN,
417# as well as automatically updating your working HEAD:
4511c899 418 git-svn dcommit
20b1d700 419# Append svn:ignore settings to the default git exclude file:
8f22562c 420 git-svn show-ignore >> .git/info/exclude
20b1d700 421------------------------------------------------------------------------
3397f9df 422
0d313b2b
EW
423Tracking and contributing to an entire Subversion-managed project
424(complete with a trunk, tags and branches):
0d313b2b
EW
425
426------------------------------------------------------------------------
a81ed0b6
EW
427# Clone a repo (like git clone):
428 git-svn clone http://svn.foo.org/project -T trunk -b branches -t tags
429# View all branches and tags you have cloned:
430 git branch -r
431# Reset your master to trunk (or any other branch, replacing 'trunk'
432# with the appropriate name):
433 git reset --hard remotes/trunk
434# You may only dcommit to one branch/tag/trunk at a time. The usage
20f50f16 435# of dcommit/rebase/show-ignore should be the same as above.
0d313b2b
EW
436------------------------------------------------------------------------
437
2eff1425
EW
438REBASE VS. PULL/MERGE
439---------------------
2e93115e
EW
440
441Originally, git-svn recommended that the remotes/git-svn branch be
2eff1425
EW
442pulled or merged from. This is because the author favored
443'git-svn set-tree B' to commit a single head rather than the
444'git-svn set-tree A..B' notation to commit multiple commits.
445
446If you use 'git-svn set-tree A..B' to commit several diffs and you do
447not have the latest remotes/git-svn merged into my-branch, you should
a81ed0b6 448use 'git-svn rebase' to update your work branch instead of 'git pull' or
2eff1425
EW
449'git merge'. 'pull/merge' can cause non-linear history to be flattened
450when committing into SVN, which can lead to merge commits reversing
451previous commits in SVN.
2e93115e 452
3397f9df
EW
453DESIGN PHILOSOPHY
454-----------------
455Merge tracking in Subversion is lacking and doing branched development
4511c899
EW
456with Subversion is cumbersome as a result. git-svn does not do
457automated merge/branch tracking by default and leaves it entirely up to
a836a0e1
EW
458the user on the git side. git-svn does however follow copy
459history of the directory that it is tracking, however (much like
460how 'svn log' works).
1d52aba8 461
3397f9df
EW
462BUGS
463----
e8f5d908 464
a81ed0b6
EW
465We ignore all SVN properties except svn:executable. Any unhandled
466properties are logged to $GIT_DIR/svn/<refname>/unhandled.log
3397f9df 467
bbe0c9b8
EW
468Renamed and copied directories are not detected by git and hence not
469tracked when committing to SVN. I do not plan on adding support for
470this as it's quite difficult and time-consuming to get working for all
a81ed0b6
EW
471the possible corner cases (git doesn't do it, either). Committing
472renamed and copied files are fully supported if they're similar enough
473for git to detect them.
bbe0c9b8 474
a836a0e1
EW
475CONFIGURATION
476-------------
477
478git-svn stores [svn-remote] configuration information in the
479repository .git/config file. It is similar the core git
480[remote] sections except 'fetch' keys do not accept glob
481arguments; but they are instead handled by the 'branches'
482and 'tags' keys. Since some SVN repositories are oddly
483configured with multiple projects glob expansions such those
484listed below are allowed:
485
486------------------------------------------------------------------------
487[svn-remote "project-a"]
488 url = http://server.org/svn
489 branches = branches/*/project-a:refs/remotes/project-a/branches/*
490 tags = tags/*/project-a:refs/remotes/project-a/tags/*
491 trunk = trunk/project-a:refs/remotes/project-a/trunk
492------------------------------------------------------------------------
493
494Keep in mind that the '*' (asterisk) wildcard of the local ref
495(left of the ':') *must* be the farthest right path component;
496however the remote wildcard may be anywhere as long as it's own
497independent path componet (surrounded by '/' or EOL). This
498type of configuration is not automatically created by 'init' and
499should be manually entered with a text-editor or using
500gitlink:git-config[1]
501
2e93115e
EW
502SEE ALSO
503--------
504gitlink:git-rebase[1]
505
3397f9df
EW
506Author
507------
508Written by Eric Wong <normalperson@yhbt.net>.
509
510Documentation
511-------------
512Written by Eric Wong <normalperson@yhbt.net>.