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