Skip to content

Commit 2b05d9f

Browse files
committed
Merge branch 'sl/maint-git-svn-docs' into maint
* sl/maint-git-svn-docs: git-svn: Note about tags. git-svn: Expand documentation for --follow-parent git-svn: Recommend use of structure options. git-svn: Document branches with at-sign(@).
2 parents 4017edc + 008c208 commit 2b05d9f

File tree

1 file changed

+85
-6
lines changed

1 file changed

+85
-6
lines changed

Documentation/git-svn.txt

Lines changed: 85 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,10 +628,19 @@ ADVANCED OPTIONS
628628
Default: "svn"
629629

630630
--follow-parent::
631+
This option is only relevant if we are tracking branches (using
632+
one of the repository layout options --trunk, --tags,
633+
--branches, --stdlayout). For each tracked branch, try to find
634+
out where its revision was copied from, and set
635+
a suitable parent in the first git commit for the branch.
631636
This is especially helpful when we're tracking a directory
632-
that has been moved around within the repository, or if we
633-
started tracking a branch and never tracked the trunk it was
634-
descended from. This feature is enabled by default, use
637+
that has been moved around within the repository. If this
638+
feature is disabled, the branches created by 'git svn' will all
639+
be linear and not share any history, meaning that there will be
640+
no information on where branches were branched off or merged.
641+
However, following long/convoluted histories can take a long
642+
time, so disabling this feature may speed up the cloning
643+
process. This feature is enabled by default, use
635644
--no-follow-parent to disable it.
636645
+
637646
[verse]
@@ -739,7 +748,8 @@ for rewriteRoot and rewriteUUID which can be used together.
739748
BASIC EXAMPLES
740749
--------------
741750

742-
Tracking and contributing to the trunk of a Subversion-managed project:
751+
Tracking and contributing to the trunk of a Subversion-managed project
752+
(ignoring tags and branches):
743753

744754
------------------------------------------------------------------------
745755
# Clone a repo (like git clone):
@@ -764,8 +774,10 @@ Tracking and contributing to an entire Subversion-managed project
764774
(complete with a trunk, tags and branches):
765775

766776
------------------------------------------------------------------------
767-
# Clone a repo (like git clone):
768-
git svn clone http://svn.example.com/project -T trunk -b branches -t tags
777+
# Clone a repo with standard SVN directory layout (like git clone):
778+
git svn clone http://svn.example.com/project --stdlayout
779+
# Or, if the repo uses a non-standard directory layout:
780+
git svn clone http://svn.example.com/project -T tr -b branch -t tag
769781
# View all branches and tags you have cloned:
770782
git branch -r
771783
# Create a new branch in SVN
@@ -830,6 +842,52 @@ inside git back upstream to SVN users. Therefore it is advised that
830842
users keep history as linear as possible inside git to ease
831843
compatibility with SVN (see the CAVEATS section below).
832844

845+
HANDLING OF SVN BRANCHES
846+
------------------------
847+
If 'git svn' is configured to fetch branches (and --follow-branches
848+
is in effect), it sometimes creates multiple git branches for one
849+
SVN branch, where the addtional branches have names of the form
850+
'branchname@nnn' (with nnn an SVN revision number). These additional
851+
branches are created if 'git svn' cannot find a parent commit for the
852+
first commit in an SVN branch, to connect the branch to the history of
853+
the other branches.
854+
855+
Normally, the first commit in an SVN branch consists
856+
of a copy operation. 'git svn' will read this commit to get the SVN
857+
revision the branch was created from. It will then try to find the
858+
git commit that corresponds to this SVN revision, and use that as the
859+
parent of the branch. However, it is possible that there is no suitable
860+
git commit to serve as parent. This will happen, among other reasons,
861+
if the SVN branch is a copy of a revision that was not fetched by 'git
862+
svn' (e.g. because it is an old revision that was skipped with
863+
'--revision'), or if in SVN a directory was copied that is not tracked
864+
by 'git svn' (such as a branch that is not tracked at all, or a
865+
subdirectory of a tracked branch). In these cases, 'git svn' will still
866+
create a git branch, but instead of using an existing git commit as the
867+
parent of the branch, it will read the SVN history of the directory the
868+
branch was copied from and create appropriate git commits. This is
869+
indicated by the message "Initializing parent: <branchname>".
870+
871+
Additionally, it will create a special branch named
872+
'<branchname>@<SVN-Revision>', where <SVN-Revision> is the SVN revision
873+
number the branch was copied from. This branch will point to the newly
874+
created parent commit of the branch. If in SVN the branch was deleted
875+
and later recreated from a different version, there will be multiple
876+
such branches with an '@'.
877+
878+
Note that this may mean that multiple git commits are created for a
879+
single SVN revision.
880+
881+
An example: in an SVN repository with a standard
882+
trunk/tags/branches layout, a directory trunk/sub is created in r.100.
883+
In r.200, trunk/sub is branched by copying it to branches/. 'git svn
884+
clone -s' will then create a branch 'sub'. It will also create new git
885+
commits for r.100 through r.199 and use these as the history of branch
886+
'sub'. Thus there will be two git commits for each revision from r.100
887+
to r.199 (one containing trunk/, one containing trunk/sub/). Finally,
888+
it will create a branch 'sub@200' pointing to the new parent commit of
889+
branch 'sub' (i.e. the commit for r.200 and trunk/sub/).
890+
833891
CAVEATS
834892
-------
835893

@@ -871,6 +929,21 @@ already dcommitted. It is considered bad practice to --amend commits
871929
you've already pushed to a remote repository for other users, and
872930
dcommit with SVN is analogous to that.
873931

932+
When cloning an SVN repository, if none of the options for describing
933+
the repository layout is used (--trunk, --tags, --branches,
934+
--stdlayout), 'git svn clone' will create a git repository with
935+
completely linear history, where branches and tags appear as separate
936+
directories in the working copy. While this is the easiest way to get a
937+
copy of a complete repository, for projects with many branches it will
938+
lead to a working copy many times larger than just the trunk. Thus for
939+
projects using the standard directory structure (trunk/branches/tags),
940+
it is recommended to clone with option '--stdlayout'. If the project
941+
uses a non-standard structure, and/or if branches and tags are not
942+
required, it is easiest to only clone one directory (typically trunk),
943+
without giving any repository layout options. If the full history with
944+
branches and tags is required, the options '--trunk' / '--branches' /
945+
'--tags' must be used.
946+
874947
When using multiple --branches or --tags, 'git svn' does not automatically
875948
handle name collisions (for example, if two branches from different paths have
876949
the same name, or if a branch and a tag have the same name). In these cases,
@@ -894,6 +967,12 @@ the possible corner cases (git doesn't do it, either). Committing
894967
renamed and copied files is fully supported if they're similar enough
895968
for git to detect them.
896969

970+
In SVN, it is possible (though discouraged) to commit changes to a tag
971+
(because a tag is just a directory copy, thus technically the same as a
972+
branch). When cloning an SVN repository, 'git svn' cannot know if such a
973+
commit to a tag will happen in the future. Thus it acts conservatively
974+
and imports all SVN tags as branches, prefixing the tag name with 'tags/'.
975+
897976
CONFIGURATION
898977
-------------
899978

0 commit comments

Comments
 (0)