1GIT-SVN(1) Git Manual GIT-SVN(1)
2
3
4
6 git-svn - Bidirectional operation between a Subversion repository and
7 Git
8
10 git svn <command> [<options>] [<arguments>]
11
12
14 git svn is a simple conduit for changesets between Subversion and Git.
15 It provides a bidirectional flow of changes between a Subversion and a
16 Git repository.
17
18 git svn can track a standard Subversion repository, following the
19 common "trunk/branches/tags" layout, with the --stdlayout option. It
20 can also follow branches and tags in any layout with the -T/-t/-b
21 options (see options to init below, and also the clone command).
22
23 Once tracking a Subversion repository (with any of the above methods),
24 the Git repository can be updated from Subversion by the fetch command
25 and Subversion updated from Git by the dcommit command.
26
28 init
29 Initializes an empty Git repository with additional metadata
30 directories for git svn. The Subversion URL may be specified as a
31 command-line argument, or as full URL arguments to -T/-t/-b.
32 Optionally, the target directory to operate on can be specified as
33 a second argument. Normally this command initializes the current
34 directory.
35
36 -T<trunk_subdir>, --trunk=<trunk_subdir>, -t<tags_subdir>,
37 --tags=<tags_subdir>, -b<branches_subdir>,
38 --branches=<branches_subdir>, -s, --stdlayout
39 These are optional command-line options for init. Each of these
40 flags can point to a relative repository path
41 (--tags=project/tags) or a full url
42 (--tags=https://foo.org/project/tags). You can specify more
43 than one --tags and/or --branches options, in case your
44 Subversion repository places tags or branches under multiple
45 paths. The option --stdlayout is a shorthand way of setting
46 trunk,tags,branches as the relative paths, which is the
47 Subversion default. If any of the other options are given as
48 well, they take precedence.
49
50 --no-metadata
51 Set the noMetadata option in the [svn-remote] config. This
52 option is not recommended, please read the svn.noMetadata
53 section of this manpage before using this option.
54
55 --use-svm-props
56 Set the useSvmProps option in the [svn-remote] config.
57
58 --use-svnsync-props
59 Set the useSvnsyncProps option in the [svn-remote] config.
60
61 --rewrite-root=<URL>
62 Set the rewriteRoot option in the [svn-remote] config.
63
64 --rewrite-uuid=<UUID>
65 Set the rewriteUUID option in the [svn-remote] config.
66
67 --username=<user>
68 For transports that SVN handles authentication for (http,
69 https, and plain svn), specify the username. For other
70 transports (e.g. svn+ssh://), you must include the username in
71 the URL, e.g. svn+ssh://foo@svn.bar.com/project
72
73 --prefix=<prefix>
74 This allows one to specify a prefix which is prepended to the
75 names of remotes if trunk/branches/tags are specified. The
76 prefix does not automatically include a trailing slash, so be
77 sure you include one in the argument if that is what you want.
78 If --branches/-b is specified, the prefix must include a
79 trailing slash. Setting a prefix (with a trailing slash) is
80 strongly encouraged in any case, as your SVN-tracking refs will
81 then be located at "refs/remotes/$prefix/", which is compatible
82 with Git’s own remote-tracking ref layout
83 (refs/remotes/$remote/). Setting a prefix is also useful if you
84 wish to track multiple projects that share a common repository.
85 By default, the prefix is set to origin/.
86
87 Note
88 Before Git v2.0, the default prefix was "" (no prefix).
89 This meant that SVN-tracking refs were put at
90 "refs/remotes/*", which is incompatible with how Git’s own
91 remote-tracking refs are organized. If you still want the
92 old default, you can get it by passing --prefix "" on the
93 command line (--prefix="" may not work if your Perl’s
94 Getopt::Long is < v2.37).
95
96 --ignore-refs=<regex>
97 When passed to init or clone this regular expression will be
98 preserved as a config key. See fetch for a description of
99 --ignore-refs.
100
101 --ignore-paths=<regex>
102 When passed to init or clone this regular expression will be
103 preserved as a config key. See fetch for a description of
104 --ignore-paths.
105
106 --include-paths=<regex>
107 When passed to init or clone this regular expression will be
108 preserved as a config key. See fetch for a description of
109 --include-paths.
110
111 --no-minimize-url
112 When tracking multiple directories (using --stdlayout,
113 --branches, or --tags options), git svn will attempt to connect
114 to the root (or highest allowed level) of the Subversion
115 repository. This default allows better tracking of history if
116 entire projects are moved within a repository, but may cause
117 issues on repositories where read access restrictions are in
118 place. Passing --no-minimize-url will allow git svn to accept
119 URLs as-is without attempting to connect to a higher level
120 directory. This option is off by default when only one
121 URL/branch is tracked (it would do little good).
122
123 fetch
124 Fetch unfetched revisions from the Subversion remote we are
125 tracking. The name of the [svn-remote "..."] section in the
126 $GIT_DIR/config file may be specified as an optional command-line
127 argument.
128
129 This automatically updates the rev_map if needed (see
130 $GIT_DIR/svn/**/.rev_map.* in the FILES section below for
131 details).
132
133 --localtime
134 Store Git commit times in the local time zone instead of UTC.
135 This makes git log (even without --date=local) show the same
136 times that svn log would in the local time zone.
137
138 This doesn’t interfere with interoperating with the Subversion
139 repository you cloned from, but if you wish for your local Git
140 repository to be able to interoperate with someone else’s local
141 Git repository, either don’t use this option or you should both
142 use it in the same local time zone.
143
144 --parent
145 Fetch only from the SVN parent of the current HEAD.
146
147 --ignore-refs=<regex>
148 Ignore refs for branches or tags matching the Perl regular
149 expression. A "negative look-ahead assertion" like
150 ^refs/remotes/origin/(?!tags/wanted-tag|wanted-branch).*$ can
151 be used to allow only certain refs.
152
153 config key: svn-remote.<name>.ignore-refs
154
155 If the ignore-refs configuration key is set, and the
156 command-line option is also given, both regular expressions
157 will be used.
158
159 --ignore-paths=<regex>
160 This allows one to specify a Perl regular expression that will
161 cause skipping of all matching paths from checkout from SVN.
162 The --ignore-paths option should match for every fetch
163 (including automatic fetches due to clone, dcommit, rebase,
164 etc) on a given repository.
165
166 config key: svn-remote.<name>.ignore-paths
167
168 If the ignore-paths configuration key is set, and the
169 command-line option is also given, both regular expressions
170 will be used.
171
172 Examples:
173
174 Skip "doc*" directory for every fetch
175
176 --ignore-paths="^doc"
177
178
179 Skip "branches" and "tags" of first level directories
180
181 --ignore-paths="^[^/]+/(?:branches|tags)"
182
183
184 --include-paths=<regex>
185 This allows one to specify a Perl regular expression that will
186 cause the inclusion of only matching paths from checkout from
187 SVN. The --include-paths option should match for every fetch
188 (including automatic fetches due to clone, dcommit, rebase,
189 etc) on a given repository. --ignore-paths takes precedence
190 over --include-paths.
191
192 config key: svn-remote.<name>.include-paths
193
194
195 --log-window-size=<n>
196 Fetch <n> log entries per request when scanning Subversion
197 history. The default is 100. For very large Subversion
198 repositories, larger values may be needed for clone/fetch to
199 complete in reasonable time. But overly large values may lead
200 to higher memory usage and request timeouts.
201
202 clone
203 Runs init and fetch. It will automatically create a directory based
204 on the basename of the URL passed to it; or if a second argument is
205 passed; it will create a directory and work within that. It accepts
206 all arguments that the init and fetch commands accept; with the
207 exception of --fetch-all and --parent. After a repository is
208 cloned, the fetch command will be able to update revisions without
209 affecting the working tree; and the rebase command will be able to
210 update the working tree with the latest changes.
211
212 --preserve-empty-dirs
213 Create a placeholder file in the local Git repository for each
214 empty directory fetched from Subversion. This includes
215 directories that become empty by removing all entries in the
216 Subversion repository (but not the directory itself). The
217 placeholder files are also tracked and removed when no longer
218 necessary.
219
220 --placeholder-filename=<filename>
221 Set the name of placeholder files created by
222 --preserve-empty-dirs. Default: ".gitignore"
223
224 rebase
225 This fetches revisions from the SVN parent of the current HEAD and
226 rebases the current (uncommitted to SVN) work against it.
227
228 This works similarly to svn update or git pull except that it
229 preserves linear history with git rebase instead of git merge for
230 ease of dcommitting with git svn.
231
232 This accepts all options that git svn fetch and git rebase accept.
233 However, --fetch-all only fetches from the current [svn-remote],
234 and not all [svn-remote] definitions.
235
236 Like git rebase; this requires that the working tree be clean and
237 have no uncommitted changes.
238
239 This automatically updates the rev_map if needed (see
240 $GIT_DIR/svn/**/.rev_map.* in the FILES section below for
241 details).
242
243 -l, --local
244 Do not fetch remotely; only run git rebase against the last
245 fetched commit from the upstream SVN.
246
247 dcommit
248 Commit each diff from the current branch directly to the SVN
249 repository, and then rebase or reset (depending on whether or not
250 there is a diff between SVN and head). This will create a revision
251 in SVN for each commit in Git.
252
253 When an optional Git branch name (or a Git commit object name) is
254 specified as an argument, the subcommand works on the specified
255 branch, not on the current branch.
256
257 Use of dcommit is preferred to set-tree (below).
258
259 --no-rebase
260 After committing, do not rebase or reset.
261
262 --commit-url <URL>
263 Commit to this SVN URL (the full path). This is intended to
264 allow existing git svn repositories created with one transport
265 method (e.g. svn:// or http:// for anonymous read) to be
266 reused if a user is later given access to an alternate
267 transport method (e.g. svn+ssh:// or https://) for commit.
268
269 config key: svn-remote.<name>.commiturl
270 config key: svn.commiturl (overwrites all svn-remote.<name>.commiturl options)
271
272 Note that the SVN URL of the commiturl config key includes the
273 SVN branch. If you rather want to set the commit URL for an
274 entire SVN repository use svn-remote.<name>.pushurl instead.
275
276 Using this option for any other purpose (don’t ask) is very
277 strongly discouraged.
278
279 --mergeinfo=<mergeinfo>
280 Add the given merge information during the dcommit (e.g.
281 --mergeinfo="/branches/foo:1-10"). All svn server versions can
282 store this information (as a property), and svn clients
283 starting from version 1.5 can make use of it. To specify merge
284 information from multiple branches, use a single space
285 character between the branches (--mergeinfo="/branches/foo:1-10
286 /branches/bar:3,5-6,8")
287
288 config key: svn.pushmergeinfo
289
290 This option will cause git-svn to attempt to automatically
291 populate the svn:mergeinfo property in the SVN repository when
292 possible. Currently, this can only be done when dcommitting
293 non-fast-forward merges where all parents but the first have
294 already been pushed into SVN.
295
296 --interactive
297 Ask the user to confirm that a patch set should actually be
298 sent to SVN. For each patch, one may answer "yes" (accept this
299 patch), "no" (discard this patch), "all" (accept all patches),
300 or "quit".
301
302 git svn dcommit returns immediately if answer is "no" or
303 "quit", without committing anything to SVN.
304
305 branch
306 Create a branch in the SVN repository.
307
308 -m, --message
309 Allows to specify the commit message.
310
311 -t, --tag
312 Create a tag by using the tags_subdir instead of the
313 branches_subdir specified during git svn init.
314
315 -d<path>, --destination=<path>
316 If more than one --branches (or --tags) option was given to the
317 init or clone command, you must provide the location of the
318 branch (or tag) you wish to create in the SVN repository.
319 <path> specifies which path to use to create the branch or tag
320 and should match the pattern on the left-hand side of one of
321 the configured branches or tags refspecs. You can see these
322 refspecs with the commands
323
324 git config --get-all svn-remote.<name>.branches
325 git config --get-all svn-remote.<name>.tags
326
327 where <name> is the name of the SVN repository as specified by
328 the -R option to init (or "svn" by default).
329
330 --username
331 Specify the SVN username to perform the commit as. This option
332 overrides the username configuration property.
333
334 --commit-url
335 Use the specified URL to connect to the destination Subversion
336 repository. This is useful in cases where the source SVN
337 repository is read-only. This option overrides configuration
338 property commiturl.
339
340 git config --get-all svn-remote.<name>.commiturl
341
342 --parents
343 Create parent folders. This parameter is equivalent to the
344 parameter --parents on svn cp commands and is useful for
345 non-standard repository layouts.
346
347 tag
348 Create a tag in the SVN repository. This is a shorthand for branch
349 -t.
350
351 log
352 This should make it easy to look up svn log messages when svn users
353 refer to -r/--revision numbers.
354
355 The following features from ‘svn log’ are supported:
356
357 -r <n>[:<n>], --revision=<n>[:<n>]
358 is supported, non-numeric args are not: HEAD, NEXT, BASE, PREV,
359 etc ...
360
361 -v, --verbose
362 it’s not completely compatible with the --verbose output in svn
363 log, but reasonably close.
364
365 --limit=<n>
366 is NOT the same as --max-count, doesn’t count merged/excluded
367 commits
368
369 --incremental
370 supported
371
372 New features:
373
374 --show-commit
375 shows the Git commit sha1, as well
376
377 --oneline
378 our version of --pretty=oneline
379
380
381 Note
382 SVN itself only stores times in UTC and nothing else. The
383 regular svn client converts the UTC time to the local time (or
384 based on the TZ= environment). This command has the same
385 behaviour.
386 Any other arguments are passed directly to git log
387
388 blame
389 Show what revision and author last modified each line of a file.
390 The output of this mode is format-compatible with the output of
391 ‘svn blame’ by default. Like the SVN blame command, local
392 uncommitted changes in the working tree are ignored; the version of
393 the file in the HEAD revision is annotated. Unknown arguments are
394 passed directly to git blame.
395
396 --git-format
397 Produce output in the same format as git blame, but with SVN
398 revision numbers instead of Git commit hashes. In this mode,
399 changes that haven’t been committed to SVN (including local
400 working-copy edits) are shown as revision 0.
401
402 find-rev
403 When given an SVN revision number of the form rN, returns the
404 corresponding Git commit hash (this can optionally be followed by a
405 tree-ish to specify which branch should be searched). When given a
406 tree-ish, returns the corresponding SVN revision number.
407
408 -B, --before
409 Don’t require an exact match if given an SVN revision, instead
410 find the commit corresponding to the state of the SVN
411 repository (on the current branch) at the specified revision.
412
413 -A, --after
414 Don’t require an exact match if given an SVN revision; if there
415 is not an exact match return the closest match searching
416 forward in the history.
417
418 set-tree
419 You should consider using dcommit instead of this command. Commit
420 specified commit or tree objects to SVN. This relies on your
421 imported fetch data being up to date. This makes absolutely no
422 attempts to do patching when committing to SVN, it simply
423 overwrites files with those specified in the tree or commit. All
424 merging is assumed to have taken place independently of git svn
425 functions.
426
427 create-ignore
428 Recursively finds the svn:ignore property on directories and
429 creates matching .gitignore files. The resulting files are staged
430 to be committed, but are not committed. Use -r/--revision to refer
431 to a specific revision.
432
433 show-ignore
434 Recursively finds and lists the svn:ignore property on directories.
435 The output is suitable for appending to the $GIT_DIR/info/exclude
436 file.
437
438 mkdirs
439 Attempts to recreate empty directories that core Git cannot track
440 based on information in $GIT_DIR/svn/<refname>/unhandled.log files.
441 Empty directories are automatically recreated when using "git svn
442 clone" and "git svn rebase", so "mkdirs" is intended for use after
443 commands like "git checkout" or "git reset". (See the
444 svn-remote.<name>.automkdirs config file option for more
445 information.)
446
447 commit-diff
448 Commits the diff of two tree-ish arguments from the command-line.
449 This command does not rely on being inside a git svn init-ed
450 repository. This command takes three arguments, (a) the original
451 tree to diff against, (b) the new tree result, (c) the URL of the
452 target Subversion repository. The final argument (URL) may be
453 omitted if you are working from a git svn-aware repository (that
454 has been init-ed with git svn). The -r<revision> option is required
455 for this.
456
457 The commit message is supplied either directly with the -m or -F
458 option, or indirectly from the tag or commit when the second
459 tree-ish denotes such an object, or it is requested by invoking an
460 editor (see --edit option below).
461
462 -m <msg>, --message=<msg>
463 Use the given msg as the commit message. This option disables
464 the --edit option.
465
466 -F <filename>, --file=<filename>
467 Take the commit message from the given file. This option
468 disables the --edit option.
469
470 info
471 Shows information about a file or directory similar to what ‘svn
472 info’ provides. Does not currently support a -r/--revision
473 argument. Use the --url option to output only the value of the URL:
474 field.
475
476 proplist
477 Lists the properties stored in the Subversion repository about a
478 given file or directory. Use -r/--revision to refer to a specific
479 Subversion revision.
480
481 propget
482 Gets the Subversion property given as the first argument, for a
483 file. A specific revision can be specified with -r/--revision.
484
485 propset
486 Sets the Subversion property given as the first argument, to the
487 value given as the second argument for the file given as the third
488 argument.
489
490 Example:
491
492 git svn propset svn:keywords "FreeBSD=%H" devel/py-tipper/Makefile
493
494 This will set the property svn:keywords to FreeBSD=%H for the file
495 devel/py-tipper/Makefile.
496
497 show-externals
498 Shows the Subversion externals. Use -r/--revision to specify a
499 specific revision.
500
501 gc
502 Compress $GIT_DIR/svn/<refname>/unhandled.log files and remove
503 $GIT_DIR/svn/<refname>/index files.
504
505 reset
506 Undoes the effects of fetch back to the specified revision. This
507 allows you to re-fetch an SVN revision. Normally the contents of an
508 SVN revision should never change and reset should not be necessary.
509 However, if SVN permissions change, or if you alter your
510 --ignore-paths option, a fetch may fail with "not found in commit"
511 (file not previously visible) or "checksum mismatch" (missed a
512 modification). If the problem file cannot be ignored forever (with
513 --ignore-paths) the only way to repair the repo is to use reset.
514
515 Only the rev_map and refs/remotes/git-svn are changed (see
516 $GIT_DIR/svn/**/.rev_map.* in the FILES section below for
517 details). Follow reset with a fetch and then git reset or git
518 rebase to move local branches onto the new tree.
519
520 -r <n>, --revision=<n>
521 Specify the most recent revision to keep. All later revisions
522 are discarded.
523
524 -p, --parent
525 Discard the specified revision as well, keeping the nearest
526 parent instead.
527
528 Example:
529 Assume you have local changes in "master", but you need to
530 refetch "r2".
531
532 r1---r2---r3 remotes/git-svn
533 \
534 A---B master
535
536 Fix the ignore-paths or SVN permissions problem that caused
537 "r2" to be incomplete in the first place. Then:
538
539 git svn reset -r2 -p
540 git svn fetch
541
542
543
544 r1---r2'--r3' remotes/git-svn
545 \
546 r2---r3---A---B master
547
548 Then fixup "master" with git rebase. Do NOT use git merge or
549 your history will not be compatible with a future dcommit!
550
551 git rebase --onto remotes/git-svn A^ master
552
553
554
555 r1---r2'--r3' remotes/git-svn
556 \
557 A'--B' master
558
559
561 --shared[=(false|true|umask|group|all|world|everybody)],
562 --template=<template_directory>
563 Only used with the init command. These are passed directly to git
564 init.
565
566 -r <arg>, --revision <arg>
567 Used with the fetch command.
568
569 This allows revision ranges for partial/cauterized history to be
570 supported. $NUMBER, $NUMBER1:$NUMBER2 (numeric ranges),
571 $NUMBER:HEAD, and BASE:$NUMBER are all supported.
572
573 This can allow you to make partial mirrors when running fetch; but
574 is generally not recommended because history will be skipped and
575 lost.
576
577 -, --stdin
578 Only used with the set-tree command.
579
580 Read a list of commits from stdin and commit them in reverse order.
581 Only the leading sha1 is read from each line, so git rev-list
582 --pretty=oneline output can be used.
583
584 --rmdir
585 Only used with the dcommit, set-tree and commit-diff commands.
586
587 Remove directories from the SVN tree if there are no files left
588 behind. SVN can version empty directories, and they are not removed
589 by default if there are no files left in them. Git cannot version
590 empty directories. Enabling this flag will make the commit to SVN
591 act like Git.
592
593 config key: svn.rmdir
594
595
596 -e, --edit
597 Only used with the dcommit, set-tree and commit-diff commands.
598
599 Edit the commit message before committing to SVN. This is off by
600 default for objects that are commits, and forced on when committing
601 tree objects.
602
603 config key: svn.edit
604
605
606 -l<num>, --find-copies-harder
607 Only used with the dcommit, set-tree and commit-diff commands.
608
609 They are both passed directly to git diff-tree; see git-diff-
610 tree(1) for more information.
611
612 config key: svn.l
613 config key: svn.findcopiesharder
614
615
616 -A<filename>, --authors-file=<filename>
617 Syntax is compatible with the file used by git cvsimport but an
618 empty email address can be supplied with <>:
619
620 loginname = Joe User <user@example.com>
621
622 If this option is specified and git svn encounters an SVN committer
623 name that does not exist in the authors-file, git svn will abort
624 operation. The user will then have to add the appropriate entry.
625 Re-running the previous git svn command after the authors-file is
626 modified should continue operation.
627
628 config key: svn.authorsfile
629
630
631 --authors-prog=<filename>
632 If this option is specified, for each SVN committer name that does
633 not exist in the authors file, the given file is executed with the
634 committer name as the first argument. The program is expected to
635 return a single line of the form "Name <email>" or "Name <>", which
636 will be treated as if included in the authors file.
637
638 Due to historical reasons a relative filename is first searched
639 relative to the current directory for init and clone and relative
640 to the root of the working tree for fetch. If filename is not
641 found, it is searched like any other command in $PATH.
642
643 config key: svn.authorsProg
644
645
646 -q, --quiet
647 Make git svn less verbose. Specify a second time to make it even
648 less verbose.
649
650 -m, --merge, -s<strategy>, --strategy=<strategy>, -p, --preserve-merges
651 These are only used with the dcommit and rebase commands.
652
653 Passed directly to git rebase when using dcommit if a git reset
654 cannot be used (see dcommit).
655
656 -n, --dry-run
657 This can be used with the dcommit, rebase, branch and tag commands.
658
659 For dcommit, print out the series of Git arguments that would show
660 which diffs would be committed to SVN.
661
662 For rebase, display the local branch associated with the upstream
663 svn repository associated with the current branch and the URL of
664 svn repository that will be fetched from.
665
666 For branch and tag, display the urls that will be used for copying
667 when creating the branch or tag.
668
669 --use-log-author
670 When retrieving svn commits into Git (as part of fetch, rebase, or
671 dcommit operations), look for the first From: or Signed-off-by:
672 line in the log message and use that as the author string.
673
674 config key: svn.useLogAuthor
675
676
677 --add-author-from
678 When committing to svn from Git (as part of set-tree or dcommit
679 operations), if the existing log message doesn’t already have a
680 From: or Signed-off-by: line, append a From: line based on the Git
681 commit’s author string. If you use this, then --use-log-author will
682 retrieve a valid author string for all commits.
683
684 config key: svn.addAuthorFrom
685
686
688 -i<GIT_SVN_ID>, --id <GIT_SVN_ID>
689 This sets GIT_SVN_ID (instead of using the environment). This
690 allows the user to override the default refname to fetch from when
691 tracking a single URL. The log and dcommit commands no longer
692 require this switch as an argument.
693
694 -R<remote name>, --svn-remote <remote name>
695 Specify the [svn-remote "<remote name>"] section to use, this
696 allows SVN multiple repositories to be tracked. Default: "svn"
697
698 --follow-parent
699 This option is only relevant if we are tracking branches (using one
700 of the repository layout options --trunk, --tags, --branches,
701 --stdlayout). For each tracked branch, try to find out where its
702 revision was copied from, and set a suitable parent in the first
703 Git commit for the branch. This is especially helpful when we’re
704 tracking a directory that has been moved around within the
705 repository. If this feature is disabled, the branches created by
706 git svn will all be linear and not share any history, meaning that
707 there will be no information on where branches were branched off or
708 merged. However, following long/convoluted histories can take a
709 long time, so disabling this feature may speed up the cloning
710 process. This feature is enabled by default, use --no-follow-parent
711 to disable it.
712
713 config key: svn.followparent
714
715
717 svn.noMetadata, svn-remote.<name>.noMetadata
718 This gets rid of the git-svn-id: lines at the end of every commit.
719
720 This option can only be used for one-shot imports as git svn will
721 not be able to fetch again without metadata. Additionally, if you
722 lose your $GIT_DIR/svn/**/.rev_map.* files, git svn will not be
723 able to rebuild them.
724
725 The git svn log command will not work on repositories using this,
726 either. Using this conflicts with the useSvmProps option for
727 (hopefully) obvious reasons.
728
729 This option is NOT recommended as it makes it difficult to track
730 down old references to SVN revision numbers in existing
731 documentation, bug reports, and archives. If you plan to eventually
732 migrate from SVN to Git and are certain about dropping SVN history,
733 consider git-filter-repo[1] instead. filter-repo also allows
734 reformatting of metadata for ease-of-reading and rewriting
735 authorship info for non-"svn.authorsFile" users.
736
737 svn.useSvmProps, svn-remote.<name>.useSvmProps
738 This allows git svn to re-map repository URLs and UUIDs from
739 mirrors created using SVN::Mirror (or svk) for metadata.
740
741 If an SVN revision has a property, "svm:headrev", it is likely that
742 the revision was created by SVN::Mirror (also used by SVK). The
743 property contains a repository UUID and a revision. We want to make
744 it look like we are mirroring the original URL, so introduce a
745 helper function that returns the original identity URL and UUID,
746 and use it when generating metadata in commit messages.
747
748 svn.useSvnsyncProps, svn-remote.<name>.useSvnsyncprops
749 Similar to the useSvmProps option; this is for users of the
750 svnsync(1) command distributed with SVN 1.4.x and later.
751
752 svn-remote.<name>.rewriteRoot
753 This allows users to create repositories from alternate URLs. For
754 example, an administrator could run git svn on the server locally
755 (accessing via file://) but wish to distribute the repository with
756 a public http:// or svn:// URL in the metadata so users of it will
757 see the public URL.
758
759 svn-remote.<name>.rewriteUUID
760 Similar to the useSvmProps option; this is for users who need to
761 remap the UUID manually. This may be useful in situations where the
762 original UUID is not available via either useSvmProps or
763 useSvnsyncProps.
764
765 svn-remote.<name>.pushurl
766 Similar to Git’s remote.<name>.pushurl, this key is designed to be
767 used in cases where url points to an SVN repository via a read-only
768 transport, to provide an alternate read/write transport. It is
769 assumed that both keys point to the same repository. Unlike
770 commiturl, pushurl is a base path. If either commiturl or pushurl
771 could be used, commiturl takes precedence.
772
773 svn.brokenSymlinkWorkaround
774 This disables potentially expensive checks to workaround broken
775 symlinks checked into SVN by broken clients. Set this option to
776 "false" if you track a SVN repository with many empty blobs that
777 are not symlinks. This option may be changed while git svn is
778 running and take effect on the next revision fetched. If unset, git
779 svn assumes this option to be "true".
780
781 svn.pathnameencoding
782 This instructs git svn to recode pathnames to a given encoding. It
783 can be used by windows users and by those who work in non-utf8
784 locales to avoid corrupted file names with non-ASCII characters.
785 Valid encodings are the ones supported by Perl’s Encode module.
786
787 svn-remote.<name>.automkdirs
788 Normally, the "git svn clone" and "git svn rebase" commands attempt
789 to recreate empty directories that are in the Subversion
790 repository. If this option is set to "false", then empty
791 directories will only be created if the "git svn mkdirs" command is
792 run explicitly. If unset, git svn assumes this option to be "true".
793
794 Since the noMetadata, rewriteRoot, rewriteUUID, useSvnsyncProps and
795 useSvmProps options all affect the metadata generated and used by git
796 svn; they must be set in the configuration file before any history is
797 imported and these settings should never be changed once they are set.
798
799 Additionally, only one of these options can be used per svn-remote
800 section because they affect the git-svn-id: metadata line, except for
801 rewriteRoot and rewriteUUID which can be used together.
802
804 Tracking and contributing to the trunk of a Subversion-managed project
805 (ignoring tags and branches):
806
807 # Clone a repo (like git clone):
808 git svn clone http://svn.example.com/project/trunk
809 # Enter the newly cloned directory:
810 cd trunk
811 # You should be on master branch, double-check with 'git branch'
812 git branch
813 # Do some work and commit locally to Git:
814 git commit ...
815 # Something is committed to SVN, rebase your local changes against the
816 # latest changes in SVN:
817 git svn rebase
818 # Now commit your changes (that were committed previously using Git) to SVN,
819 # as well as automatically updating your working HEAD:
820 git svn dcommit
821 # Append svn:ignore settings to the default Git exclude file:
822 git svn show-ignore >> .git/info/exclude
823
824
825 Tracking and contributing to an entire Subversion-managed project
826 (complete with a trunk, tags and branches):
827
828 # Clone a repo with standard SVN directory layout (like git clone):
829 git svn clone http://svn.example.com/project --stdlayout --prefix svn/
830 # Or, if the repo uses a non-standard directory layout:
831 git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/
832 # View all branches and tags you have cloned:
833 git branch -r
834 # Create a new branch in SVN
835 git svn branch waldo
836 # Reset your master to trunk (or any other branch, replacing 'trunk'
837 # with the appropriate name):
838 git reset --hard svn/trunk
839 # You may only dcommit to one branch/tag/trunk at a time. The usage
840 # of dcommit/rebase/show-ignore should be the same as above.
841
842
843 The initial git svn clone can be quite time-consuming (especially for
844 large Subversion repositories). If multiple people (or one person with
845 multiple machines) want to use git svn to interact with the same
846 Subversion repository, you can do the initial git svn clone to a
847 repository on a server and have each person clone that repository with
848 git clone:
849
850 # Do the initial import on a server
851 ssh server "cd /pub && git svn clone http://svn.example.com/project [options...]"
852 # Clone locally - make sure the refs/remotes/ space matches the server
853 mkdir project
854 cd project
855 git init
856 git remote add origin server:/pub/project
857 git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
858 git fetch
859 # Prevent fetch/pull from remote Git server in the future,
860 # we only want to use git svn for future updates
861 git config --remove-section remote.origin
862 # Create a local branch from one of the branches just fetched
863 git checkout -b master FETCH_HEAD
864 # Initialize 'git svn' locally (be sure to use the same URL and
865 # --stdlayout/-T/-b/-t/--prefix options as were used on server)
866 git svn init http://svn.example.com/project [options...]
867 # Pull the latest changes from Subversion
868 git svn rebase
869
870
872 Prefer to use git svn rebase or git rebase, rather than git pull or git
873 merge to synchronize unintegrated commits with a git svn branch. Doing
874 so will keep the history of unintegrated commits linear with respect to
875 the upstream SVN repository and allow the use of the preferred git svn
876 dcommit subcommand to push unintegrated commits back into SVN.
877
878 Originally, git svn recommended that developers pulled or merged from
879 the git svn branch. This was because the author favored git svn
880 set-tree B to commit a single head rather than the git svn set-tree
881 A..B notation to commit multiple commits. Use of git pull or git merge
882 with git svn set-tree A..B will cause non-linear history to be
883 flattened when committing into SVN and this can lead to merge commits
884 unexpectedly reversing previous commits in SVN.
885
887 While git svn can track copy history (including branches and tags) for
888 repositories adopting a standard layout, it cannot yet represent merge
889 history that happened inside git back upstream to SVN users. Therefore
890 it is advised that users keep history as linear as possible inside Git
891 to ease compatibility with SVN (see the CAVEATS section below).
892
894 If git svn is configured to fetch branches (and --follow-branches is in
895 effect), it sometimes creates multiple Git branches for one SVN branch,
896 where the additional branches have names of the form branchname@nnn
897 (with nnn an SVN revision number). These additional branches are
898 created if git svn cannot find a parent commit for the first commit in
899 an SVN branch, to connect the branch to the history of the other
900 branches.
901
902 Normally, the first commit in an SVN branch consists of a copy
903 operation. git svn will read this commit to get the SVN revision the
904 branch was created from. It will then try to find the Git commit that
905 corresponds to this SVN revision, and use that as the parent of the
906 branch. However, it is possible that there is no suitable Git commit to
907 serve as parent. This will happen, among other reasons, if the SVN
908 branch is a copy of a revision that was not fetched by git svn (e.g.
909 because it is an old revision that was skipped with --revision), or if
910 in SVN a directory was copied that is not tracked by git svn (such as a
911 branch that is not tracked at all, or a subdirectory of a tracked
912 branch). In these cases, git svn will still create a Git branch, but
913 instead of using an existing Git commit as the parent of the branch, it
914 will read the SVN history of the directory the branch was copied from
915 and create appropriate Git commits. This is indicated by the message
916 "Initializing parent: <branchname>".
917
918 Additionally, it will create a special branch named
919 <branchname>@<SVN-Revision>, where <SVN-Revision> is the SVN revision
920 number the branch was copied from. This branch will point to the newly
921 created parent commit of the branch. If in SVN the branch was deleted
922 and later recreated from a different version, there will be multiple
923 such branches with an @.
924
925 Note that this may mean that multiple Git commits are created for a
926 single SVN revision.
927
928 An example: in an SVN repository with a standard trunk/tags/branches
929 layout, a directory trunk/sub is created in r.100. In r.200, trunk/sub
930 is branched by copying it to branches/. git svn clone -s will then
931 create a branch sub. It will also create new Git commits for r.100
932 through r.199 and use these as the history of branch sub. Thus there
933 will be two Git commits for each revision from r.100 to r.199 (one
934 containing trunk/, one containing trunk/sub/). Finally, it will create
935 a branch sub@200 pointing to the new parent commit of branch sub (i.e.
936 the commit for r.200 and trunk/sub/).
937
939 For the sake of simplicity and interoperating with Subversion, it is
940 recommended that all git svn users clone, fetch and dcommit directly
941 from the SVN server, and avoid all git clone/pull/merge/push operations
942 between Git repositories and branches. The recommended method of
943 exchanging code between Git branches and users is git format-patch and
944 git am, or just 'dcommit’ing to the SVN repository.
945
946 Running git merge or git pull is NOT recommended on a branch you plan
947 to dcommit from because Subversion users cannot see any merges you’ve
948 made. Furthermore, if you merge or pull from a Git branch that is a
949 mirror of an SVN branch, dcommit may commit to the wrong branch.
950
951 If you do merge, note the following rule: git svn dcommit will attempt
952 to commit on top of the SVN commit named in
953
954 git log --grep=^git-svn-id: --first-parent -1
955
956
957 You must therefore ensure that the most recent commit of the branch you
958 want to dcommit to is the first parent of the merge. Chaos will ensue
959 otherwise, especially if the first parent is an older commit on the
960 same SVN branch.
961
962 git clone does not clone branches under the refs/remotes/ hierarchy or
963 any git svn metadata, or config. So repositories created and managed
964 with using git svn should use rsync for cloning, if cloning is to be
965 done at all.
966
967 Since dcommit uses rebase internally, any Git branches you git push to
968 before dcommit on will require forcing an overwrite of the existing ref
969 on the remote repository. This is generally considered bad practice,
970 see the git-push(1) documentation for details.
971
972 Do not use the --amend option of git-commit(1) on a change you’ve
973 already dcommitted. It is considered bad practice to --amend commits
974 you’ve already pushed to a remote repository for other users, and
975 dcommit with SVN is analogous to that.
976
977 When cloning an SVN repository, if none of the options for describing
978 the repository layout is used (--trunk, --tags, --branches,
979 --stdlayout), git svn clone will create a Git repository with
980 completely linear history, where branches and tags appear as separate
981 directories in the working copy. While this is the easiest way to get a
982 copy of a complete repository, for projects with many branches it will
983 lead to a working copy many times larger than just the trunk. Thus for
984 projects using the standard directory structure (trunk/branches/tags),
985 it is recommended to clone with option --stdlayout. If the project uses
986 a non-standard structure, and/or if branches and tags are not required,
987 it is easiest to only clone one directory (typically trunk), without
988 giving any repository layout options. If the full history with branches
989 and tags is required, the options --trunk / --branches / --tags must be
990 used.
991
992 When using multiple --branches or --tags, git svn does not
993 automatically handle name collisions (for example, if two branches from
994 different paths have the same name, or if a branch and a tag have the
995 same name). In these cases, use init to set up your Git repository
996 then, before your first fetch, edit the $GIT_DIR/config file so that
997 the branches and tags are associated with different name spaces. For
998 example:
999
1000 branches = stable/*:refs/remotes/svn/stable/*
1001 branches = debug/*:refs/remotes/svn/debug/*
1002
1004 We ignore all SVN properties except svn:executable. Any unhandled
1005 properties are logged to $GIT_DIR/svn/<refname>/unhandled.log
1006
1007 Renamed and copied directories are not detected by Git and hence not
1008 tracked when committing to SVN. I do not plan on adding support for
1009 this as it’s quite difficult and time-consuming to get working for all
1010 the possible corner cases (Git doesn’t do it, either). Committing
1011 renamed and copied files is fully supported if they’re similar enough
1012 for Git to detect them.
1013
1014 In SVN, it is possible (though discouraged) to commit changes to a tag
1015 (because a tag is just a directory copy, thus technically the same as a
1016 branch). When cloning an SVN repository, git svn cannot know if such a
1017 commit to a tag will happen in the future. Thus it acts conservatively
1018 and imports all SVN tags as branches, prefixing the tag name with
1019 tags/.
1020
1022 git svn stores [svn-remote] configuration information in the repository
1023 $GIT_DIR/config file. It is similar the core Git [remote] sections
1024 except fetch keys do not accept glob arguments; but they are instead
1025 handled by the branches and tags keys. Since some SVN repositories are
1026 oddly configured with multiple projects glob expansions such those
1027 listed below are allowed:
1028
1029 [svn-remote "project-a"]
1030 url = http://server.org/svn
1031 fetch = trunk/project-a:refs/remotes/project-a/trunk
1032 branches = branches/*/project-a:refs/remotes/project-a/branches/*
1033 branches = branches/release_*:refs/remotes/project-a/branches/release_*
1034 branches = branches/re*se:refs/remotes/project-a/branches/*
1035 tags = tags/*/project-a:refs/remotes/project-a/tags/*
1036
1037
1038 Keep in mind that the * (asterisk) wildcard of the local ref (right of
1039 the :) must be the farthest right path component; however the remote
1040 wildcard may be anywhere as long as it’s an independent path component
1041 (surrounded by / or EOL). This type of configuration is not
1042 automatically created by init and should be manually entered with a
1043 text-editor or using git config.
1044
1045 Also note that only one asterisk is allowed per word. For example:
1046
1047 branches = branches/re*se:refs/remotes/project-a/branches/*
1048
1049 will match branches release, rese, re123se, however
1050
1051 branches = branches/re*s*e:refs/remotes/project-a/branches/*
1052
1053 will produce an error.
1054
1055 It is also possible to fetch a subset of branches or tags by using a
1056 comma-separated list of names within braces. For example:
1057
1058 [svn-remote "huge-project"]
1059 url = http://server.org/svn
1060 fetch = trunk/src:refs/remotes/trunk
1061 branches = branches/{red,green}/src:refs/remotes/project-a/branches/*
1062 tags = tags/{1.0,2.0}/src:refs/remotes/project-a/tags/*
1063
1064
1065 Multiple fetch, branches, and tags keys are supported:
1066
1067 [svn-remote "messy-repo"]
1068 url = http://server.org/svn
1069 fetch = trunk/project-a:refs/remotes/project-a/trunk
1070 fetch = branches/demos/june-project-a-demo:refs/remotes/project-a/demos/june-demo
1071 branches = branches/server/*:refs/remotes/project-a/branches/*
1072 branches = branches/demos/2011/*:refs/remotes/project-a/2011-demos/*
1073 tags = tags/server/*:refs/remotes/project-a/tags/*
1074
1075
1076 Creating a branch in such a configuration requires disambiguating which
1077 location to use using the -d or --destination flag:
1078
1079 $ git svn branch -d branches/server release-2-3-0
1080
1081
1082 Note that git-svn keeps track of the highest revision in which a branch
1083 or tag has appeared. If the subset of branches or tags is changed after
1084 fetching, then $GIT_DIR/svn/.metadata must be manually edited to remove
1085 (or reset) branches-maxRev and/or tags-maxRev as appropriate.
1086
1088 $GIT_DIR/svn/**/.rev_map.*
1089 Mapping between Subversion revision numbers and Git commit names.
1090 In a repository where the noMetadata option is not set, this can be
1091 rebuilt from the git-svn-id: lines that are at the end of every
1092 commit (see the svn.noMetadata section above for details).
1093
1094 git svn fetch and git svn rebase automatically update the rev_map
1095 if it is missing or not up to date. git svn reset automatically
1096 rewinds it.
1097
1099 git-rebase(1)
1100
1102 Part of the git(1) suite
1103
1105 1. git-filter-repo
1106 https://github.com/newren/git-filter-repo
1107
1108
1109
1110Git 2.24.1 12/10/2019 GIT-SVN(1)