Documentation / git-svn.txton commit Documentation: begin discussion of git-remote in user manual (d5cd5de)
   1git-svn(1)
   2==========
   3
   4NAME
   5----
   6git-svn - bidirectional operation between Subversion 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 and geared towards tracking multiple branches.
  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; but it cannot (yet) automatically detect new
  23branches and tags like git-svnimport does.
  24
  25git-svn is especially useful when it comes to tracking repositories
  26not organized in the way Subversion developers recommend (trunk,
  27branches, tags directories).
  28
  29COMMANDS
  30--------
  31--
  32
  33'init'::
  34        Creates an empty git repository with additional metadata
  35        directories for git-svn.  The Subversion URL must be specified
  36        as a command-line argument.  Optionally, the target directory
  37        to operate on can be specified as a second argument.  Normally
  38        this command initializes the current directory.
  39
  40'fetch'::
  41
  42Fetch unfetched revisions from the Subversion URL we are
  43tracking.  refs/remotes/git-svn will be updated to the
  44latest revision.
  45
  46Note: You should never attempt to modify the remotes/git-svn
  47branch outside of git-svn.  Instead, create a branch from
  48remotes/git-svn and work on that branch.  Use the 'dcommit'
  49command (see below) to write git commits back to
  50remotes/git-svn.
  51
  52See '<<fetch-args,Additional Fetch Arguments>>' if you are interested in
  53manually joining branches on commit.
  54
  55'dcommit'::
  56        Commit each diff from a specified head directly to the SVN
  57        repository, and then rebase or reset (depending on whether or
  58        not there is a diff between SVN and head).  This will create
  59        a revision in SVN for each commit in git.
  60        It is recommended that you run git-svn fetch and rebase (not
  61        pull or merge) your commits against the latest changes in the
  62        SVN repository.
  63        An optional command-line argument may be specified as an
  64        alternative to HEAD.
  65        This is advantageous over 'set-tree' (below) because it produces
  66        cleaner, more linear history.
  67
  68'log'::
  69        This should make it easy to look up svn log messages when svn
  70        users refer to -r/--revision numbers.
  71
  72        The following features from `svn log' are supported:
  73
  74        --revision=<n>[:<n>] - is supported, non-numeric args are not:
  75                               HEAD, NEXT, BASE, PREV, etc ...
  76        -v/--verbose         - it's not completely compatible with
  77                               the --verbose output in svn log, but
  78                               reasonably close.
  79        --limit=<n>          - is NOT the same as --max-count,
  80                               doesn't count merged/excluded commits
  81        --incremental        - supported
  82
  83        New features:
  84
  85        --show-commit        - shows the git commit sha1, as well
  86        --oneline            - our version of --pretty=oneline
  87
  88        Any other arguments are passed directly to `git log'
  89
  90'set-tree'::
  91        You should consider using 'dcommit' instead of this command.
  92        Commit specified commit or tree objects to SVN.  This relies on
  93        your imported fetch data being up-to-date.  This makes
  94        absolutely no attempts to do patching when committing to SVN, it
  95        simply overwrites files with those specified in the tree or
  96        commit.  All merging is assumed to have taken place
  97        independently of git-svn functions.
  98
  99'rebuild'::
 100        Not a part of daily usage, but this is a useful command if
 101        you've just cloned a repository (using gitlink:git-clone[1]) that was
 102        tracked with git-svn.  Unfortunately, git-clone does not clone
 103        git-svn metadata and the svn working tree that git-svn uses for
 104        its operations.  This rebuilds the metadata so git-svn can
 105        resume fetch operations.  A Subversion URL may be optionally
 106        specified at the command-line if the directory/repository you're
 107        tracking has moved or changed protocols.
 108
 109'show-ignore'::
 110        Recursively finds and lists the svn:ignore property on
 111        directories.  The output is suitable for appending to
 112        the $GIT_DIR/info/exclude file.
 113
 114'commit-diff'::
 115        Commits the diff of two tree-ish arguments from the
 116        command-line.  This command is intended for interopability with
 117        git-svnimport and does not rely on being inside an git-svn
 118        init-ed repository.  This command takes three arguments, (a) the
 119        original tree to diff against, (b) the new tree result, (c) the
 120        URL of the target Subversion repository.  The final argument
 121        (URL) may be omitted if you are working from a git-svn-aware
 122        repository (that has been init-ed with git-svn).
 123        The -r<revision> option is required for this.
 124
 125'graft-branches'::
 126        This command attempts to detect merges/branches from already
 127        imported history.  Techniques used currently include regexes,
 128        file copies, and tree-matches).  This command generates (or
 129        modifies) the $GIT_DIR/info/grafts file.  This command is
 130        considered experimental, and inherently flawed because
 131        merge-tracking in SVN is inherently flawed and inconsistent
 132        across different repositories.
 133
 134'multi-init'::
 135        This command supports git-svnimport-like command-line syntax for
 136        importing repositories that are layed out as recommended by the
 137        SVN folks.  This is a bit more tolerant than the git-svnimport
 138        command-line syntax and doesn't require the user to figure out
 139        where the repository URL ends and where the repository path
 140        begins.
 141
 142'multi-fetch'::
 143        This runs fetch on all known SVN branches we're tracking.  This
 144        will NOT discover new branches (unlike git-svnimport), so
 145        multi-init will need to be re-run (it's idempotent).
 146
 147--
 148
 149OPTIONS
 150-------
 151--
 152
 153--shared::
 154--template=<template_directory>::
 155        Only used with the 'init' command.
 156        These are passed directly to gitlink:git-init-db[1].
 157
 158-r <ARG>::
 159--revision <ARG>::
 160
 161Only used with the 'fetch' command.
 162
 163Takes any valid -r<argument> svn would accept and passes it
 164directly to svn. -r<ARG1>:<ARG2> ranges and "{" DATE "}" syntax
 165is also supported.  This is passed directly to svn, see svn
 166documentation for more details.
 167
 168This can allow you to make partial mirrors when running fetch.
 169
 170-::
 171--stdin::
 172
 173Only used with the 'set-tree' command.
 174
 175Read a list of commits from stdin and commit them in reverse
 176order.  Only the leading sha1 is read from each line, so
 177git-rev-list --pretty=oneline output can be used.
 178
 179--rmdir::
 180
 181Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
 182
 183Remove directories from the SVN tree if there are no files left
 184behind.  SVN can version empty directories, and they are not
 185removed by default if there are no files left in them.  git
 186cannot version empty directories.  Enabling this flag will make
 187the commit to SVN act like git.
 188
 189repo-config key: svn.rmdir
 190
 191-e::
 192--edit::
 193
 194Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
 195
 196Edit the commit message before committing to SVN.  This is off by
 197default for objects that are commits, and forced on when committing
 198tree objects.
 199
 200repo-config key: svn.edit
 201
 202-l<num>::
 203--find-copies-harder::
 204
 205Only used with the 'dcommit', 'set-tree' and 'commit-diff' commands.
 206
 207They are both passed directly to git-diff-tree see
 208gitlink:git-diff-tree[1] for more information.
 209
 210[verse]
 211repo-config key: svn.l
 212repo-config key: svn.findcopiesharder
 213
 214-A<filename>::
 215--authors-file=<filename>::
 216
 217Syntax is compatible with the files used by git-svnimport and
 218git-cvsimport:
 219
 220------------------------------------------------------------------------
 221        loginname = Joe User <user@example.com>
 222------------------------------------------------------------------------
 223
 224If this option is specified and git-svn encounters an SVN
 225committer name that does not exist in the authors-file, git-svn
 226will abort operation. The user will then have to add the
 227appropriate entry.  Re-running the previous git-svn command
 228after the authors-file is modified should continue operation.
 229
 230repo-config key: svn.authorsfile
 231
 232-q::
 233--quiet::
 234        Make git-svn less verbose.  This only affects git-svn if you
 235        have the SVN::* libraries installed and are using them.
 236
 237--repack[=<n>]::
 238--repack-flags=<flags>
 239        These should help keep disk usage sane for large fetches
 240        with many revisions.
 241
 242        --repack takes an optional argument for the number of revisions
 243        to fetch before repacking.  This defaults to repacking every
 244        1000 commits fetched if no argument is specified.
 245
 246        --repack-flags are passed directly to gitlink:git-repack[1].
 247
 248repo-config key: svn.repack
 249repo-config key: svn.repackflags
 250
 251-m::
 252--merge::
 253-s<strategy>::
 254--strategy=<strategy>::
 255
 256These are only used with the 'dcommit' command.
 257
 258Passed directly to git-rebase when using 'dcommit' if a
 259'git-reset' cannot be used (see dcommit).
 260
 261-n::
 262--dry-run::
 263
 264This is only used with the 'dcommit' command.
 265
 266Print out the series of git arguments that would show
 267which diffs would be committed to SVN.
 268
 269--
 270
 271ADVANCED OPTIONS
 272----------------
 273--
 274
 275-b<refname>::
 276--branch <refname>::
 277Used with 'fetch', 'dcommit' or 'set-tree'.
 278
 279This can be used to join arbitrary git branches to remotes/git-svn
 280on new commits where the tree object is equivalent.
 281
 282When used with different GIT_SVN_ID values, tags and branches in
 283SVN can be tracked this way, as can some merges where the heads
 284end up having completely equivalent content.  This can even be
 285used to track branches across multiple SVN _repositories_.
 286
 287This option may be specified multiple times, once for each
 288branch.
 289
 290repo-config key: svn.branch
 291
 292-i<GIT_SVN_ID>::
 293--id <GIT_SVN_ID>::
 294
 295This sets GIT_SVN_ID (instead of using the environment).  See the
 296section on
 297'<<tracking-multiple-repos,Tracking Multiple Repositories or Branches>>'
 298for more information on using GIT_SVN_ID.
 299
 300--follow-parent::
 301        This is especially helpful when we're tracking a directory
 302        that has been moved around within the repository, or if we
 303        started tracking a branch and never tracked the trunk it was
 304        descended from.
 305
 306        This relies on the SVN::* libraries to work.
 307
 308repo-config key: svn.followparent
 309
 310--no-metadata::
 311        This gets rid of the git-svn-id: lines at the end of every commit.
 312
 313        With this, you lose the ability to use the rebuild command.  If
 314        you ever lose your .git/svn/git-svn/.rev_db file, you won't be
 315        able to fetch again, either.  This is fine for one-shot imports.
 316
 317        The 'git-svn log' command will not work on repositories using this,
 318        either.
 319
 320repo-config key: svn.nometadata
 321
 322--
 323
 324COMPATIBILITY OPTIONS
 325---------------------
 326--
 327
 328--upgrade::
 329Only used with the 'rebuild' command.
 330
 331Run this if you used an old version of git-svn that used
 332"git-svn-HEAD" instead of "remotes/git-svn" as the branch
 333for tracking the remote.
 334
 335--no-ignore-externals::
 336Only used with the 'fetch' and 'rebuild' command.
 337
 338This command has no effect when you are using the SVN::*
 339libraries with git, svn:externals are always avoided.
 340
 341By default, git-svn passes --ignore-externals to svn to avoid
 342fetching svn:external trees into git.  Pass this flag to enable
 343externals tracking directly via git.
 344
 345Versions of svn that do not support --ignore-externals are
 346automatically detected and this flag will be automatically
 347enabled for them.
 348
 349Otherwise, do not enable this flag unless you know what you're
 350doing.
 351
 352repo-config key: svn.noignoreexternals
 353
 354--ignore-nodate::
 355Only used with the 'fetch' command.
 356
 357By default git-svn will crash if it tries to import a revision
 358from SVN which has '(no date)' listed as the date of the revision.
 359This is repository corruption on SVN's part, plain and simple.
 360But sometimes you really need those revisions anyway.
 361
 362If supplied git-svn will convert '(no date)' entries to the UNIX
 363epoch (midnight on Jan. 1, 1970).  Yes, that's probably very wrong.
 364SVN was very wrong.
 365
 366--
 367
 368Basic Examples
 369~~~~~~~~~~~~~~
 370
 371Tracking and contributing to a the trunk of a Subversion-managed project:
 372
 373------------------------------------------------------------------------
 374# Initialize a repo (like git init-db):
 375        git-svn init http://svn.foo.org/project/trunk
 376# Fetch remote revisions:
 377        git-svn fetch
 378# Create your own branch to hack on:
 379        git checkout -b my-branch remotes/git-svn
 380# Do some work, and then commit your new changes to SVN, as well as
 381# automatically updating your working HEAD:
 382        git-svn dcommit
 383# Something is committed to SVN, rebase the latest into your branch:
 384        git-svn fetch && git rebase remotes/git-svn
 385# Append svn:ignore settings to the default git exclude file:
 386        git-svn show-ignore >> .git/info/exclude
 387------------------------------------------------------------------------
 388
 389Tracking and contributing to an entire Subversion-managed project
 390(complete with a trunk, tags and branches):
 391See also:
 392'<<tracking-multiple-repos,Tracking Multiple Repositories or Branches>>'
 393
 394------------------------------------------------------------------------
 395# Initialize a repo (like git init-db):
 396        git-svn multi-init http://svn.foo.org/project \
 397                -T trunk -b branches -t tags
 398# Fetch remote revisions:
 399        git-svn multi-fetch
 400# Create your own branch of trunk to hack on:
 401        git checkout -b my-trunk remotes/trunk
 402# Do some work, and then commit your new changes to SVN, as well as
 403# automatically updating your working HEAD:
 404        git-svn dcommit -i trunk
 405# Something has been committed to trunk, rebase the latest into your branch:
 406        git-svn multi-fetch && git rebase remotes/trunk
 407# Append svn:ignore settings of trunk to the default git exclude file:
 408        git-svn show-ignore -i trunk >> .git/info/exclude
 409# Check for new branches and tags (no arguments are needed):
 410        git-svn multi-init
 411------------------------------------------------------------------------
 412
 413REBASE VS. PULL/MERGE
 414---------------------
 415
 416Originally, git-svn recommended that the remotes/git-svn branch be
 417pulled or merged from.  This is because the author favored
 418'git-svn set-tree B' to commit a single head rather than the
 419'git-svn set-tree A..B' notation to commit multiple commits.
 420
 421If you use 'git-svn set-tree A..B' to commit several diffs and you do
 422not have the latest remotes/git-svn merged into my-branch, you should
 423use 'git rebase' to update your work branch instead of 'git pull' or
 424'git merge'.  'pull/merge' can cause non-linear history to be flattened
 425when committing into SVN, which can lead to merge commits reversing
 426previous commits in SVN.
 427
 428DESIGN PHILOSOPHY
 429-----------------
 430Merge tracking in Subversion is lacking and doing branched development
 431with Subversion is cumbersome as a result.  git-svn does not do
 432automated merge/branch tracking by default and leaves it entirely up to
 433the user on the git side.
 434
 435[[tracking-multiple-repos]]
 436TRACKING MULTIPLE REPOSITORIES OR BRANCHES
 437------------------------------------------
 438Because git-svn does not care about relationships between different
 439branches or directories in a Subversion repository, git-svn has a simple
 440hack to allow it to track an arbitrary number of related _or_ unrelated
 441SVN repositories via one git repository.  Simply use the --id/-i flag or
 442set the GIT_SVN_ID environment variable to a name other other than
 443"git-svn" (the default) and git-svn will ignore the contents of the
 444$GIT_DIR/svn/git-svn directory and instead do all of its work in
 445$GIT_DIR/svn/$GIT_SVN_ID for that invocation.  The interface branch will
 446be remotes/$GIT_SVN_ID, instead of remotes/git-svn.  Any
 447remotes/$GIT_SVN_ID branch should never be modified by the user outside
 448of git-svn commands.
 449
 450[[fetch-args]]
 451ADDITIONAL FETCH ARGUMENTS
 452--------------------------
 453This is for advanced users, most users should ignore this section.
 454
 455Unfetched SVN revisions may be imported as children of existing commits
 456by specifying additional arguments to 'fetch'.  Additional parents may
 457optionally be specified in the form of sha1 hex sums at the
 458command-line.  Unfetched SVN revisions may also be tied to particular
 459git commits with the following syntax:
 460
 461------------------------------------------------
 462        svn_revision_number=git_commit_sha1
 463------------------------------------------------
 464
 465This allows you to tie unfetched SVN revision 375 to your current HEAD:
 466
 467------------------------------------------------
 468        git-svn fetch 375=$(git-rev-parse HEAD)
 469------------------------------------------------
 470
 471Advanced Example: Tracking a Reorganized Repository
 472~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 473Note: this example is now obsolete if you have SVN::* libraries
 474installed.  Simply use --follow-parent when fetching.
 475
 476If you're tracking a directory that has moved, or otherwise been
 477branched or tagged off of another directory in the repository and you
 478care about the full history of the project, then you can read this
 479section.
 480
 481This is how Yann Dirson tracked the trunk of the ufoai directory when
 482the /trunk directory of his repository was moved to /ufoai/trunk and
 483he needed to continue tracking /ufoai/trunk where /trunk left off.
 484
 485------------------------------------------------------------------------
 486        # This log message shows when the repository was reorganized:
 487        r166 | ydirson | 2006-03-02 01:36:55 +0100 (Thu, 02 Mar 2006) | 1 line
 488        Changed paths:
 489           D /trunk
 490           A /ufoai/trunk (from /trunk:165)
 491
 492        # First we start tracking the old revisions:
 493        GIT_SVN_ID=git-oldsvn git-svn init \
 494                        https://svn.sourceforge.net/svnroot/ufoai/trunk
 495        GIT_SVN_ID=git-oldsvn git-svn fetch -r1:165
 496
 497        # And now, we continue tracking the new revisions:
 498        GIT_SVN_ID=git-newsvn git-svn init \
 499              https://svn.sourceforge.net/svnroot/ufoai/ufoai/trunk
 500        GIT_SVN_ID=git-newsvn git-svn fetch \
 501              166=`git-rev-parse refs/remotes/git-oldsvn`
 502------------------------------------------------------------------------
 503
 504BUGS
 505----
 506
 507If you are not using the SVN::* Perl libraries and somebody commits a
 508conflicting changeset to SVN at a bad moment (right before you commit)
 509causing a conflict and your commit to fail, your svn working tree
 510($GIT_DIR/git-svn/tree) may be dirtied.  The easiest thing to do is
 511probably just to rm -rf $GIT_DIR/git-svn/tree and run 'rebuild'.   You
 512can avoid this problem entirely by using 'dcommit'.
 513
 514We ignore all SVN properties except svn:executable.  Too difficult to
 515map them since we rely heavily on git write-tree being _exactly_ the
 516same on both the SVN and git working trees and I prefer not to clutter
 517working trees with metadata files.
 518
 519Renamed and copied directories are not detected by git and hence not
 520tracked when committing to SVN.  I do not plan on adding support for
 521this as it's quite difficult and time-consuming to get working for all
 522the possible corner cases (git doesn't do it, either).  Renamed and
 523copied files are fully supported if they're similar enough for git to
 524detect them.
 525
 526SEE ALSO
 527--------
 528gitlink:git-rebase[1]
 529
 530Author
 531------
 532Written by Eric Wong <normalperson@yhbt.net>.
 533
 534Documentation
 535-------------
 536Written by Eric Wong <normalperson@yhbt.net>.