Skip to content

Commit 7091a2d

Browse files
jherlandEric Wong
authored andcommitted
Documentation/git-svn: Promote the use of --prefix in docs + examples
Currently, the git-svn defaults to using an empty prefix, which ends up placing the SVN-tracking refs directly in refs/remotes/*. This placement runs counter to Git's convention of placing remote-tracking branches in refs/remotes/$remote/*. Furthermore, combining git-svn with "regular" Git remotes run the risk of clobbering refs under refs/remotes (e.g. if you have a git remote called "tags" with a "v1" branch, it will overlap with the git-svn's tracking branch for the "v1" tag from Subversion. Even though the git-svn refs stored in refs/remotes/* are not "proper" remote-tracking branches (since they are not covered by a proper git remote's refspec), they clearly represent a similar concept, and would benefit from following the same convention. For example, if git-svn tracks Subversion branch "foo" at refs/remotes/foo, and you create a local branch refs/heads/foo to add some commits to be pushed back to Subversion (using "git svn dcommit), then it is clearly unhelpful of Git to throw warning: refname 'foo' is ambiguous. every time you checkout, rebase, or otherwise interact with the branch. At this time, the user is better off using the --prefix=foo/ (the trailing slash is important) to git svn init/clone, to cause the SVN-tracking refs to be placed at refs/remotes/foo/* instead of refs/remotes/*. This patch updates the documentation to encourage use of --prefix. This is also in preparation for changing the default value of --prefix at some point in the future. Cc: Eric Wong <[email protected]> Signed-off-by: Johan Herland <[email protected]> Signed-off-by: Eric Wong <[email protected]>
1 parent 945b9c1 commit 7091a2d

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

Documentation/git-svn.txt

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,13 @@ COMMANDS
7979
trailing slash, so be sure you include one in the
8080
argument if that is what you want. If --branches/-b is
8181
specified, the prefix must include a trailing slash.
82-
Setting a prefix is useful if you wish to track multiple
83-
projects that share a common repository.
82+
Setting a prefix (with a trailing slash) is strongly
83+
encouraged in any case, as your SVN-tracking refs will
84+
then be located at "refs/remotes/$prefix/*", which is
85+
compatible with Git's own remote-tracking ref layout
86+
(refs/remotes/$remote/*). Setting a prefix is also useful
87+
if you wish to track multiple projects that share a common
88+
repository.
8489
--ignore-paths=<regex>;;
8590
When passed to 'init' or 'clone' this regular expression will
8691
be preserved as a config key. See 'fetch' for a description
@@ -811,16 +816,16 @@ Tracking and contributing to an entire Subversion-managed project
811816

812817
------------------------------------------------------------------------
813818
# Clone a repo with standard SVN directory layout (like git clone):
814-
git svn clone http://svn.example.com/project --stdlayout
819+
git svn clone http://svn.example.com/project --stdlayout --prefix svn/
815820
# Or, if the repo uses a non-standard directory layout:
816-
git svn clone http://svn.example.com/project -T tr -b branch -t tag
821+
git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/
817822
# View all branches and tags you have cloned:
818823
git branch -r
819824
# Create a new branch in SVN
820825
git svn branch waldo
821826
# Reset your master to trunk (or any other branch, replacing 'trunk'
822827
# with the appropriate name):
823-
git reset --hard remotes/trunk
828+
git reset --hard svn/trunk
824829
# You may only dcommit to one branch/tag/trunk at a time. The usage
825830
# of dcommit/rebase/show-ignore should be the same as above.
826831
------------------------------------------------------------------------
@@ -834,7 +839,7 @@ have each person clone that repository with 'git clone':
834839

835840
------------------------------------------------------------------------
836841
# Do the initial import on a server
837-
ssh server "cd /pub && git svn clone http://svn.example.com/project
842+
ssh server "cd /pub && git svn clone http://svn.example.com/project [options...]"
838843
# Clone locally - make sure the refs/remotes/ space matches the server
839844
mkdir project
840845
cd project
@@ -847,8 +852,9 @@ have each person clone that repository with 'git clone':
847852
git config --remove-section remote.origin
848853
# Create a local branch from one of the branches just fetched
849854
git checkout -b master FETCH_HEAD
850-
# Initialize 'git svn' locally (be sure to use the same URL and -T/-b/-t options as were used on server)
851-
git svn init http://svn.example.com/project
855+
# Initialize 'git svn' locally (be sure to use the same URL and
856+
# --stdlayout/-T/-b/-t/--prefix options as were used on server)
857+
git svn init http://svn.example.com/project [options...]
852858
# Pull the latest changes from Subversion
853859
git svn rebase
854860
------------------------------------------------------------------------
@@ -980,6 +986,15 @@ without giving any repository layout options. If the full history with
980986
branches and tags is required, the options '--trunk' / '--branches' /
981987
'--tags' must be used.
982988

989+
When using the options for describing the repository layout (--trunk,
990+
--tags, --branches, --stdlayout), please also specify the --prefix
991+
option (e.g. '--prefix=origin/') to cause your SVN-tracking refs to be
992+
placed at refs/remotes/origin/* rather than the default refs/remotes/*.
993+
The former is more compatible with the layout of Git's "regular"
994+
remote-tracking refs (refs/remotes/$remote/*), and may potentially
995+
prevent similarly named SVN branches and Git remotes from clobbering
996+
each other.
997+
983998
When using multiple --branches or --tags, 'git svn' does not automatically
984999
handle name collisions (for example, if two branches from different paths have
9851000
the same name, or if a branch and a tag have the same name). In these cases,
@@ -1042,8 +1057,8 @@ comma-separated list of names within braces. For example:
10421057
[svn-remote "huge-project"]
10431058
url = http://server.org/svn
10441059
fetch = trunk/src:refs/remotes/trunk
1045-
branches = branches/{red,green}/src:refs/remotes/branches/*
1046-
tags = tags/{1.0,2.0}/src:refs/remotes/tags/*
1060+
branches = branches/{red,green}/src:refs/remotes/project-a/branches/*
1061+
tags = tags/{1.0,2.0}/src:refs/remotes/project-a/tags/*
10471062
------------------------------------------------------------------------
10481063

10491064
Multiple fetch, branches, and tags keys are supported:

0 commit comments

Comments
 (0)