@@ -628,10 +628,19 @@ ADVANCED OPTIONS
628
628
Default: "svn"
629
629
630
630
--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.
631
636
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
635
644
--no-follow-parent to disable it.
636
645
+
637
646
[verse]
@@ -739,7 +748,8 @@ for rewriteRoot and rewriteUUID which can be used together.
739
748
BASIC EXAMPLES
740
749
--------------
741
750
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):
743
753
744
754
------------------------------------------------------------------------
745
755
# Clone a repo (like git clone):
@@ -764,8 +774,10 @@ Tracking and contributing to an entire Subversion-managed project
764
774
(complete with a trunk, tags and branches):
765
775
766
776
------------------------------------------------------------------------
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
769
781
# View all branches and tags you have cloned:
770
782
git branch -r
771
783
# Create a new branch in SVN
@@ -830,6 +842,52 @@ inside git back upstream to SVN users. Therefore it is advised that
830
842
users keep history as linear as possible inside git to ease
831
843
compatibility with SVN (see the CAVEATS section below).
832
844
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
+
833
891
CAVEATS
834
892
-------
835
893
@@ -871,6 +929,21 @@ already dcommitted. It is considered bad practice to --amend commits
871
929
you've already pushed to a remote repository for other users, and
872
930
dcommit with SVN is analogous to that.
873
931
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
+
874
947
When using multiple --branches or --tags, 'git svn' does not automatically
875
948
handle name collisions (for example, if two branches from different paths have
876
949
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
894
967
renamed and copied files is fully supported if they're similar enough
895
968
for git to detect them.
896
969
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
+
897
976
CONFIGURATION
898
977
-------------
899
978
0 commit comments