Documentation / git-svn.txton commit Check for IO errors after running a command (0f15731)
   1git-svn(1)
   2==========
   3
   4NAME
   5----
   6git-svn - Bidirectional operation between a single Subversion branch and git
   7
   8SYNOPSIS
   9--------
  10'git-svn' <command> [options] [arguments]
  11
  12DESCRIPTION
  13-----------
  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
  16read-only.
  17
  18git-svn was originally designed for an individual developer who wants a
  19bidirectional flow of changesets between a single branch in Subversion
  20and an arbitrary number of branches in git.  Since its inception,
  21git-svn has gained the ability to track multiple branches in a manner
  22similar to git-svnimport.
  23
  24git-svn is especially useful when it comes to tracking repositories
  25not organized in the way Subversion developers recommend (trunk,
  26branches, tags directories).
  27
  28COMMANDS
  29--------
  30--
  31
  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.
  40
  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.
  73
  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.
  79
  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
  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.
  98
  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.
 102
 103Like 'git-rebase'; this requires that the working tree be clean
 104and have no uncommitted changes.
 105
 106-l;;
 107--local;;
 108        Do not fetch remotely; only run 'git-rebase' against the
 109        last fetched commit from the upstream SVN.
 110
 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.
 123+
 124--no-rebase;;
 125        After committing, do not rebase or reset.
 126--
 127
 128'log'::
 129        This should make it easy to look up svn log messages when svn
 130        users refer to -r/--revision numbers.
 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'
 158
 159--
 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.
 165
 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.
 174
 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.
 179
 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.
 190
 191--
 192
 193OPTIONS
 194-------
 195--
 196
 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].
 201
 202-r <ARG>::
 203--revision <ARG>::
 204
 205Used with the 'fetch' command.
 206
 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.
 210
 211This can allow you to make partial mirrors when running fetch;
 212but is generally not recommended because history will be skipped
 213and lost.
 214
 215-::
 216--stdin::
 217
 218Only used with the 'set-tree' command.
 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.
 223
 224--rmdir::
 225
 226Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
 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.
 233
 234config key: svn.rmdir
 235
 236-e::
 237--edit::
 238
 239Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
 240
 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
 245config key: svn.edit
 246
 247-l<num>::
 248--find-copies-harder::
 249
 250Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
 251
 252They are both passed directly to git-diff-tree see
 253gitlink:git-diff-tree[1] for more information.
 254
 255[verse]
 256config key: svn.l
 257config key: svn.findcopiesharder
 258
 259-A<filename>::
 260--authors-file=<filename>::
 261
 262Syntax is compatible with the files used by git-svnimport and
 263git-cvsimport:
 264
 265------------------------------------------------------------------------
 266        loginname = Joe User <user@example.com>
 267------------------------------------------------------------------------
 268
 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.
 274
 275config key: svn.authorsfile
 276
 277-q::
 278--quiet::
 279        Make git-svn less verbose.
 280
 281--repack[=<n>]::
 282--repack-flags=<flags>::
 283
 284These should help keep disk usage sane for large fetches
 285with many revisions.
 286
 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.
 290
 291--repack-flags are passed directly to gitlink:git-repack[1].
 292
 293[verse]
 294config key: svn.repack
 295config key: svn.repackflags
 296
 297-m::
 298--merge::
 299-s<strategy>::
 300--strategy=<strategy>::
 301
 302These are only used with the 'dcommit' and 'rebase' commands.
 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
 315--
 316
 317ADVANCED OPTIONS
 318----------------
 319--
 320
 321-i<GIT_SVN_ID>::
 322--id <GIT_SVN_ID>::
 323
 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.
 328
 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"
 334
 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.
 341
 342config key: svn.followparent
 343
 344--
 345CONFIG FILE-ONLY OPTIONS
 346------------------------
 347--
 348
 349svn.noMetadata::
 350svn-remote.<name>.noMetadata::
 351
 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.
 357
 358The 'git-svn log' command will not work on repositories using
 359this, either.  Using this conflicts with the 'useSvmProps'
 360option for (hopefully) obvious reasons.
 361
 362svn.useSvmProps::
 363svn-remote.<name>.useSvmProps::
 364
 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.
 375
 376svn.useSvnsyncProps::
 377svn-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.
 381
 382svn-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.
 388
 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.
 396
 397--
 398
 399BASIC EXAMPLES
 400--------------
 401
 402Tracking and contributing to a the trunk of a Subversion-managed project:
 403
 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------------------------------------------------------------------------
 422
 423Tracking and contributing to an entire Subversion-managed project
 424(complete with a trunk, tags and branches):
 425
 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------------------------------------------------------------------------
 437
 438REBASE VS. PULL/MERGE
 439---------------------
 440
 441Originally, git-svn recommended that the remotes/git-svn branch be
 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
 448use '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
 450when committing into SVN, which can lead to merge commits reversing
 451previous commits in SVN.
 452
 453DESIGN PHILOSOPHY
 454-----------------
 455Merge tracking in Subversion is lacking and doing branched development
 456with Subversion is cumbersome as a result.  git-svn does not do
 457automated merge/branch tracking by default and leaves it entirely up to
 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).
 461
 462BUGS
 463----
 464
 465We ignore all SVN properties except svn:executable.  Any unhandled
 466properties are logged to $GIT_DIR/svn/<refname>/unhandled.log
 467
 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
 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.
 474
 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
 502SEE ALSO
 503--------
 504gitlink:git-rebase[1]
 505
 506Author
 507------
 508Written by Eric Wong <normalperson@yhbt.net>.
 509
 510Documentation
 511-------------
 512Written by Eric Wong <normalperson@yhbt.net>.