LinuxCommandLibrary

git-svn

Use Git as a Subversion client

TLDR

Clone an SVN repository

$ git svn clone [https://example.com/subversion_repo] [local_directory]
copy

Clone an SVN repository starting at a given revision number
$ git svn clone [[-r|--revision]] [1234]:HEAD [https://svn.example.net/subversion/repo] [local_directory]
copy

Update local clone from the remote SVN repository
$ git svn rebase
copy

Fetch updates from the remote SVN repository without changing the Git HEAD
$ git svn fetch
copy

Commit back to the SVN repository
$ git svn commit
copy

SYNOPSIS

git svn [<options>] [<command> [<args>]] [--] [<SVN-url-or-path>]

PARAMETERS

clone [<options>] <SVN-url>
    Clones SVN repo (full or partial) into new Git repo, like init + fetch.

init [<options>] <SVN-url>
    Initializes Git repo with SVN metadata for bidirectional tracking.

fetch [<options>]
    Fetches new SVN commits into Git refs/remotes/trunk (or similar).

rebase [<options>]
    Rebases current branch onto latest SVN changes.

dcommit [<options>]
    Pushes local Git commits to SVN as native revisions (linear history only).

log [<options>]
    Shows SVN commit logs, like git log but from SVN.

-s, --stdlayout
    Assumes standard SVN layout: trunk/branches/tags.

-T <trunk>
    Specifies SVN trunk path (default: trunk).

-b <branches>
    Specifies SVN branches path (default: branches).

-t <tags>
    Specifies SVN tags path (default: tags).

-r <rev>, --revision <rev>
    Operate on specific SVN revision(s) (e.g., HEAD:123 or 1000:HEAD).

--authors-file <file>
    Maps SVN usernames to Git author format.

-A <file>, --authors-prog <file>
    External program for dynamic SVN author mapping.

DESCRIPTION

git-svn enables seamless two-way operation between Git repositories and remote Subversion (SVN) servers. It allows cloning SVN repositories into Git (including branches/tags with proper config), fetching SVN changes into Git history, rebasing local Git commits atop SVN updates, and pushing Git commits back to SVN as native revisions via dcommit. This bridges Git's fast, branch-friendly workflow with SVN's centralized model, ideal for SVN-to-Git transitions or hybrid teams.

Workflow: Use git svn clone or init to set up; git svn fetch or rebase to sync from SVN; develop in Git; git svn dcommit to publish. Supports author mapping, revision ranges, and partial cloning. Preserves SVN metadata like logs/authors.

Limitations include linear-history focus (no true merges), slower performance on large repos, and incomplete SVN feature support (e.g., complex branches). Widely used historically for migrations.

CAVEATS

Requires linear Git history for dcommit (no merges); slow on large SVN histories; poor support for SVN merges/branches without manual config; not recommended for new projects (prefer full Git migration).

AUTHORS FILE FORMAT

Example .authors file:
svnuser = SVN User <svnuser@domain.com>
anon = Anonymous <anon@domain.com>
Use with --authors-file=.authors.

REVISION SPEC

SVN revisions via -r: BASE, HEAD, {YYYY-MM-DD}, N (number), N:M (range), N~1 (parent).

HISTORY

Created by Eric Wong in 2006 as contrib/git-svn, integrated into Git core in v1.5.3 (Feb 2007). Evolved for SVN migrations; maintenance slowed post-2010 as Git matured, but remains in Git for legacy use.

SEE ALSO

git(1), svn(1), git-clone(1), git-rebase(1), git-log(1)

Copied to clipboard