git-stash: fix "no arguments" case in documentation
[git/dscho.git] / Documentation / git-svn.txt
blob0a210e4bea49d49e9d38de402cc355ed4acc6a71
1 git-svn(1)
2 ==========
4 NAME
5 ----
6 git-svn - Bidirectional operation between a single Subversion branch and git
8 SYNOPSIS
9 --------
10 'git-svn' <command> [options] [arguments]
12 DESCRIPTION
13 -----------
14 git-svn is a simple conduit for changesets between Subversion and git.
15 It is not to be confused with gitlink:git-svnimport[1], which is
16 read-only.
18 git-svn was originally designed for an individual developer who wants a
19 bidirectional flow of changesets between a single branch in Subversion
20 and an arbitrary number of branches in git.  Since its inception,
21 git-svn has gained the ability to track multiple branches in a manner
22 similar to git-svnimport.
24 git-svn is especially useful when it comes to tracking repositories
25 not organized in the way Subversion developers recommend (trunk,
26 branches, tags directories).
28 COMMANDS
29 --------
32 'init'::
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.
41 -T<trunk_subdir>;;
42 --trunk=<trunk_subdir>;;
43 -t<tags_subdir>;;
44 --tags=<tags_subdir>;;
45 -b<branches_subdir>;;
46 --branches=<branches_subdir>;;
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)
51 --no-metadata;;
52         Set the 'noMetadata' option in the [svn-remote] config.
53 --use-svm-props;;
54         Set the 'useSvmProps' option in the [svn-remote] config.
55 --use-svnsync-props;;
56         Set the 'useSvnsyncProps' option in the [svn-remote] config.
57 --rewrite-root=<URL>;;
58         Set the 'rewriteRoot' option in the [svn-remote] config.
59 --username=<USER>;;
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
64 --prefix=<prefix>;;
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
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.
74 'fetch'::
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.
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.
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.
95 This works similarly to 'svn update' or 'git-pull' except that
96 it preserves linear history with 'git-rebase' instead of
97 'git-merge' for ease of dcommit-ing with git-svn.
99 This accepts all options that 'git-svn fetch' and 'git-rebase'
100 accepts.  However '--fetch-all' only fetches from the current
101 [svn-remote], and not all [svn-remote] definitions.
103 Like 'git-rebase'; this requires that the working tree be clean
104 and have no uncommitted changes.
106 -l;;
107 --local;;
108         Do not fetch remotely; only run 'git-rebase' against the
109         last fetched commit from the upstream SVN.
111 'dcommit'::
112         Commit each diff from a specified head directly to the SVN
113         repository, and then rebase or reset (depending on whether or
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.
119         An optional command-line argument may be specified as an
120         alternative to HEAD.
121         This is advantageous over 'set-tree' (below) because it produces
122         cleaner, more linear history.
124 --no-rebase;;
125         After committing, do not rebase or reset.
128 'log'::
129         This should make it easy to look up svn log messages when svn
130         users refer to -r/--revision numbers.
132 The following features from `svn log' are supported:
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
148 New features:
151 --show-commit;;
152         shows the git commit sha1, as well
153 --oneline;;
154         our version of --pretty=oneline
157 Any other arguments are passed directly to `git log'
160 'find-rev'::
161         When given an SVN revision number of the form 'rN', returns the
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.
166 'set-tree'::
167         You should consider using 'dcommit' instead of this command.
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.
175 'show-ignore'::
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.
180 'commit-diff'::
181         Commits the diff of two tree-ish arguments from the
182         command-line.  This command is intended for interoperability with
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).
189         The -r<revision> option is required for this.
193 OPTIONS
194 -------
197 --shared[={false|true|umask|group|all|world|everybody}]::
198 --template=<template_directory>::
199         Only used with the 'init' command.
200         These are passed directly to gitlink:git-init[1].
202 -r <ARG>::
203 --revision <ARG>::
205 Used with the 'fetch' command.
207 This allows revision ranges for partial/cauterized history
208 to be supported.  $NUMBER, $NUMBER1:$NUMBER2 (numeric ranges),
209 $NUMBER:HEAD, and BASE:$NUMBER are all supported.
211 This can allow you to make partial mirrors when running fetch;
212 but is generally not recommended because history will be skipped
213 and lost.
216 --stdin::
218 Only used with the 'set-tree' command.
220 Read a list of commits from stdin and commit them in reverse
221 order.  Only the leading sha1 is read from each line, so
222 git-rev-list --pretty=oneline output can be used.
224 --rmdir::
226 Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
228 Remove directories from the SVN tree if there are no files left
229 behind.  SVN can version empty directories, and they are not
230 removed by default if there are no files left in them.  git
231 cannot version empty directories.  Enabling this flag will make
232 the commit to SVN act like git.
234 config key: svn.rmdir
236 -e::
237 --edit::
239 Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
241 Edit the commit message before committing to SVN.  This is off by
242 default for objects that are commits, and forced on when committing
243 tree objects.
245 config key: svn.edit
247 -l<num>::
248 --find-copies-harder::
250 Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
252 They are both passed directly to git-diff-tree see
253 gitlink:git-diff-tree[1] for more information.
255 [verse]
256 config key: svn.l
257 config key: svn.findcopiesharder
259 -A<filename>::
260 --authors-file=<filename>::
262 Syntax is compatible with the files used by git-svnimport and
263 git-cvsimport:
265 ------------------------------------------------------------------------
266         loginname = Joe User <user@example.com>
267 ------------------------------------------------------------------------
269 If this option is specified and git-svn encounters an SVN
270 committer name that does not exist in the authors-file, git-svn
271 will abort operation. The user will then have to add the
272 appropriate entry.  Re-running the previous git-svn command
273 after the authors-file is modified should continue operation.
275 config key: svn.authorsfile
277 -q::
278 --quiet::
279         Make git-svn less verbose.
281 --repack[=<n>]::
282 --repack-flags=<flags>::
284 These should help keep disk usage sane for large fetches
285 with many revisions.
287 --repack takes an optional argument for the number of revisions
288 to fetch before repacking.  This defaults to repacking every
289 1000 commits fetched if no argument is specified.
291 --repack-flags are passed directly to gitlink:git-repack[1].
293 [verse]
294 config key: svn.repack
295 config key: svn.repackflags
297 -m::
298 --merge::
299 -s<strategy>::
300 --strategy=<strategy>::
302 These are only used with the 'dcommit' and 'rebase' commands.
304 Passed directly to git-rebase when using 'dcommit' if a
305 'git-reset' cannot be used (see dcommit).
307 -n::
308 --dry-run::
310 This is only used with the 'dcommit' command.
312 Print out the series of git arguments that would show
313 which diffs would be committed to SVN.
317 ADVANCED OPTIONS
318 ----------------
321 -i<GIT_SVN_ID>::
322 --id <GIT_SVN_ID>::
324 This sets GIT_SVN_ID (instead of using the environment).  This
325 allows the user to override the default refname to fetch from
326 when tracking a single URL.  The 'log' and 'dcommit' commands
327 no longer require this switch as an argument.
329 -R<remote name>::
330 --svn-remote <remote name>::
331         Specify the [svn-remote "<remote name>"] section to use,
332         this allows SVN multiple repositories to be tracked.
333         Default: "svn"
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
339         descended from. This feature is enabled by default, use
340         --no-follow-parent to disable it.
342 config key: svn.followparent
345 CONFIG FILE-ONLY OPTIONS
346 ------------------------
349 svn.noMetadata::
350 svn-remote.<name>.noMetadata::
352 This gets rid of the git-svn-id: lines at the end of every commit.
354 If you lose your .git/svn/git-svn/.rev_db file, git-svn will not
355 be able to rebuild it and you won't be able to fetch again,
356 either.  This is fine for one-shot imports.
358 The 'git-svn log' command will not work on repositories using
359 this, either.  Using this conflicts with the 'useSvmProps'
360 option for (hopefully) obvious reasons.
362 svn.useSvmProps::
363 svn-remote.<name>.useSvmProps::
365 This allows git-svn to re-map repository URLs and UUIDs from
366 mirrors created using SVN::Mirror (or svk) for metadata.
368 If an SVN revision has a property, "svm:headrev", it is likely
369 that the revision was created by SVN::Mirror (also used by SVK).
370 The property contains a repository UUID and a revision.  We want
371 to make it look like we are mirroring the original URL, so
372 introduce a helper function that returns the original identity
373 URL and UUID, and use it when generating metadata in commit
374 messages.
376 svn.useSvnsyncProps::
377 svn-remote.<name>.useSvnsyncprops::
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.
382 svn-remote.<name>.rewriteRoot::
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.
389 Since the noMetadata, rewriteRoot, useSvnsyncProps and useSvmProps
390 options all affect the metadata generated and used by git-svn; they
391 *must* be set in the configuration file before any history is imported
392 and these settings should never be changed once they are set.
394 Additionally, only one of these four options can be used per-svn-remote
395 section because they affect the 'git-svn-id:' metadata line.
399 BASIC EXAMPLES
400 --------------
402 Tracking and contributing to a the trunk of a Subversion-managed project:
404 ------------------------------------------------------------------------
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:
418         git-svn dcommit
419 # Append svn:ignore settings to the default git exclude file:
420         git-svn show-ignore >> .git/info/exclude
421 ------------------------------------------------------------------------
423 Tracking and contributing to an entire Subversion-managed project
424 (complete with a trunk, tags and branches):
426 ------------------------------------------------------------------------
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
435 # of dcommit/rebase/show-ignore should be the same as above.
436 ------------------------------------------------------------------------
438 REBASE VS. PULL/MERGE
439 ---------------------
441 Originally, git-svn recommended that the remotes/git-svn branch be
442 pulled 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.
446 If you use 'git-svn set-tree A..B' to commit several diffs and you do
447 not have the latest remotes/git-svn merged into my-branch, you should
448 use 'git-svn rebase' to update your work branch instead of 'git pull' or
449 'git merge'.  'pull/merge' can cause non-linear history to be flattened
450 when committing into SVN, which can lead to merge commits reversing
451 previous commits in SVN.
453 DESIGN PHILOSOPHY
454 -----------------
455 Merge tracking in Subversion is lacking and doing branched development
456 with Subversion is cumbersome as a result.  git-svn does not do
457 automated merge/branch tracking by default and leaves it entirely up to
458 the user on the git side.  git-svn does however follow copy
459 history of the directory that it is tracking, however (much like
460 how 'svn log' works).
462 BUGS
463 ----
465 We ignore all SVN properties except svn:executable.  Any unhandled
466 properties are logged to $GIT_DIR/svn/<refname>/unhandled.log
468 Renamed and copied directories are not detected by git and hence not
469 tracked when committing to SVN.  I do not plan on adding support for
470 this as it's quite difficult and time-consuming to get working for all
471 the possible corner cases (git doesn't do it, either).  Committing
472 renamed and copied files are fully supported if they're similar enough
473 for git to detect them.
475 CONFIGURATION
476 -------------
478 git-svn stores [svn-remote] configuration information in the
479 repository .git/config file.  It is similar the core git
480 [remote] sections except 'fetch' keys do not accept glob
481 arguments; but they are instead handled by the 'branches'
482 and 'tags' keys.  Since some SVN repositories are oddly
483 configured with multiple projects glob expansions such those
484 listed below are allowed:
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 ------------------------------------------------------------------------
494 Keep in mind that the '*' (asterisk) wildcard of the local ref
495 (left of the ':') *must* be the farthest right path component;
496 however the remote wildcard may be anywhere as long as it's own
497 independent path componet (surrounded by '/' or EOL).   This
498 type of configuration is not automatically created by 'init' and
499 should be manually entered with a text-editor or using
500 gitlink:git-config[1]
502 SEE ALSO
503 --------
504 gitlink:git-rebase[1]
506 Author
507 ------
508 Written by Eric Wong <normalperson@yhbt.net>.
510 Documentation
511 -------------
512 Written by Eric Wong <normalperson@yhbt.net>.