contrib/git-svn: tell the user to not modify git-svn-HEAD directly
[git.git] / contrib / git-svn / git-svn.txt
1 git-svn(1)
2 ==========
3
4 NAME
5 ----
6 git-svn - bidirectional operation between a single Subversion branch and git
7
8 SYNOPSIS
9 --------
10 'git-svn' <command> [options] [arguments]
11
12 DESCRIPTION
13 -----------
14 git-svn is a simple conduit for changesets between a single Subversion
15 branch and git.
16
17 git-svn is not to be confused with git-svnimport.  The were designed
18 with very different goals in mind.
19
20 git-svn is designed for an individual developer who wants a
21 bidirectional flow of changesets between a single branch in Subversion
22 and an arbitrary number of branches in git.  git-svnimport is designed
23 for read-only operation on repositories that match a particular layout
24 (albeit the recommended one by SVN developers).
25
26 For importing svn, git-svnimport is potentially more powerful when
27 operating on repositories organized under the recommended
28 trunk/branch/tags structure, and should be faster, too.
29
30 git-svn completely ignores the very limited view of branching that
31 Subversion has.  This allows git-svn to be much easier to use,
32 especially on repositories that are not organized in a manner that
33 git-svnimport is designed for.
34
35 COMMANDS
36 --------
37 init::
38         Creates an empty git repository with additional metadata
39         directories for git-svn.  The SVN_URL must be specified
40         at this point.
41
42 fetch::
43         Fetch unfetched revisions from the SVN_URL we are tracking.
44         refs/heads/git-svn-HEAD will be updated to the latest revision.
45
46         Note: You should never attempt to modify the git-svn-HEAD branch
47         outside of git-svn.  Instead, create a branch from git-svn-HEAD
48         and work on that branch.  Use the 'commit' command (see below)
49         to write git commits back to git-svn-HEAD.
50
51 commit::
52         Commit specified commit or tree objects to SVN.  This relies on
53         your imported fetch data being up-to-date.  This makes
54         absolutely no attempts to do patching when committing to SVN, it
55         simply overwrites files with those specified in the tree or
56         commit.  All merging is assumed to have taken place
57         independently of git-svn functions.
58
59 rebuild::
60         Not a part of daily usage, but this is a useful command if
61         you've just cloned a repository (using git-clone) that was
62         tracked with git-svn.  Unfortunately, git-clone does not clone
63         git-svn metadata and the svn working tree that git-svn uses for
64         its operations.  This rebuilds the metadata so git-svn can
65         resume fetch operations.  SVN_URL may be optionally specified if
66         the directory/repository you're tracking has moved or changed
67         protocols.
68
69 show-ignore::
70         Recursively finds and lists the svn:ignore property on
71         directories.  The output is suitable for appending to
72         the $GIT_DIR/info/exclude file.
73
74 OPTIONS
75 -------
76 -r <ARG>::
77 --revision <ARG>::
78         Only used with the 'fetch' command.
79
80         Takes any valid -r<argument> svn would accept and passes it
81         directly to svn. -r<ARG1>:<ARG2> ranges and "{" DATE "}" syntax
82         is also supported.  This is passed directly to svn, see svn
83         documentation for more details.
84
85         This can allow you to make partial mirrors when running fetch.
86
87 -::
88 --stdin::
89         Only used with the 'commit' command.
90
91         Read a list of commits from stdin and commit them in reverse
92         order.  Only the leading sha1 is read from each line, so
93         git-rev-list --pretty=oneline output can be used.
94
95 --rmdir::
96         Only used with the 'commit' command.
97
98         Remove directories from the SVN tree if there are no files left
99         behind.  SVN can version empty directories, and they are not
100         removed by default if there are no files left in them.  git
101         cannot version empty directories.  Enabling this flag will make
102         the commit to SVN act like git.
103
104 -e::
105 --edit::
106         Only used with the 'commit' command.
107
108         Edit the commit message before committing to SVN.  This is off by
109         default for objects that are commits, and forced on when committing
110         tree objects.
111
112 -l<num>::
113 --find-copies-harder::
114         Both of these are only used with the 'commit' command.
115
116         They are both passed directly to git-diff-tree see
117         git-diff-tree(1) for more information.
118
119 COMPATIBILITY OPTIONS
120 ---------------------
121 --no-ignore-externals::
122         Only used with the 'fetch' and 'rebuild' command.
123
124         By default, git-svn passes --ignore-externals to svn to avoid
125         fetching svn:external trees into git.  Pass this flag to enable
126         externals tracking directly via git.
127
128         Versions of svn that do not support --ignore-externals are
129         automatically detected and this flag will be automatically
130         enabled for them.
131
132         Otherwise, do not enable this flag unless you know what you're
133         doing.
134
135 --no-stop-on-copy::
136         Only used with the 'fetch' command.
137
138         By default, git-svn passes --stop-on-copy to avoid dealing with
139         the copied/renamed branch directory problem entirely.  A
140         copied/renamed branch is the result of a <SVN_URL> being created
141         in the past from a different source.  These are problematic to
142         deal with even when working purely with svn if you work inside
143         subdirectories.
144
145         Do not use this flag unless you know exactly what you're getting
146         yourself into.  You have been warned.
147
148 Examples
149 ~~~~~~~~
150
151 Tracking and contributing to an Subversion managed-project:
152
153 # Initialize a tree (like git init-db)::
154         git-svn init http://svn.foo.org/project/trunk
155 # Fetch remote revisions::
156         git-svn fetch
157 # Create your own branch to hack on::
158         git checkout -b my-branch git-svn-HEAD
159 # Commit only the git commits you want to SVN::
160         git-svn commit <tree-ish> [<tree-ish_2> ...]
161 # Commit all the git commits from my-branch that don't exist in SVN::
162         git commit git-svn-HEAD..my-branch
163 # Something is committed to SVN, pull the latest into your branch::
164         git-svn fetch && git pull . git-svn-HEAD
165 # Append svn:ignore settings to the default git exclude file:
166         git-svn show-ignore >> .git/info/exclude
167
168 DESIGN PHILOSOPHY
169 -----------------
170 Merge tracking in Subversion is lacking and doing branched development
171 with Subversion is cumbersome as a result.  git-svn completely forgoes
172 any automated merge/branch tracking on the Subversion side and leaves it
173 entirely up to the user on the git side.  It's simply not worth it to do
174 a useful translation when the the original signal is weak.
175
176 TRACKING MULTIPLE REPOSITORIES OR BRANCHES
177 ------------------------------------------
178 This is for advanced users, most users should ignore this section.
179
180 Because git-svn does not care about relationships between different
181 branches or directories in a Subversion repository, git-svn has a simple
182 hack to allow it to track an arbitrary number of related _or_ unrelated
183 SVN repositories via one git repository.  Simply set the GIT_SVN_ID
184 environment variable to a name other other than "git-svn" (the default)
185 and git-svn will ignore the contents of the $GIT_DIR/git-svn directory
186 and instead do all of its work in $GIT_DIR/$GIT_SVN_ID for that
187 invocation.  The interface branch will be $GIT_SVN_ID-HEAD, instead of
188 git-svn-HEAD.  Any $GIT_SVN_ID-HEAD branch should never be modified
189 by the user outside of git-svn commands.
190
191 ADDITIONAL FETCH ARGUMENTS
192 --------------------------
193 This is for advanced users, most users should ignore this section.
194
195 Unfetched SVN revisions may be imported as children of existing commits
196 by specifying additional arguments to 'fetch'.  Additional parents may
197 optionally be specified in the form of sha1 hex sums at the
198 command-line.  Unfetched SVN revisions may also be tied to particular
199 git commits with the following syntax:
200
201         svn_revision_number=git_commit_sha1
202
203 This allows you to tie unfetched SVN revision 375 to your current HEAD::
204
205         git-svn fetch 375=$(git-rev-parse HEAD)
206
207 BUGS
208 ----
209 If somebody commits a conflicting changeset to SVN at a bad moment
210 (right before you commit) causing a conflict and your commit to fail,
211 your svn working tree ($GIT_DIR/git-svn/tree) may be dirtied.  The
212 easiest thing to do is probably just to rm -rf $GIT_DIR/git-svn/tree and
213 run 'rebuild'.
214
215 We ignore all SVN properties except svn:executable.  Too difficult to
216 map them since we rely heavily on git write-tree being _exactly_ the
217 same on both the SVN and git working trees and I prefer not to clutter
218 working trees with metadata files.
219
220 svn:keywords can't be ignored in Subversion (at least I don't know of
221 a way to ignore them).
222
223 Renamed and copied directories are not detected by git and hence not
224 tracked when committing to SVN.  I do not plan on adding support for
225 this as it's quite difficult and time-consuming to get working for all
226 the possible corner cases (git doesn't do it, either).  Renamed and
227 copied files are fully supported if they're similar enough for git to
228 detect them.
229
230 Author
231 ------
232 Written by Eric Wong <normalperson@yhbt.net>.
233
234 Documentation
235 -------------
236 Written by Eric Wong <normalperson@yhbt.net>.