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