http://chucklu.github.io/Blog/2014/12/24/git-svn.html
如何使用git和TortoiseGit来操作svn的版本库
1.首先clone svn的版本库,使用此命令git svn clone https:// ,如果是比较大的版本库的话,会耗时比较久
2.修改.git\info\exclude文件,进行忽略文件的设置 比如 bin/ obj/ *.suo *.user
3.对代码做出修改,然后可以使用TortoiseGit的右键菜单,svn dcommit 会提示按照什么风格进行提交代码(这个有待测试)
4.如果有其他人修改了代码,并提交到svn上,需要用TortoiseGit的右键菜单svn fetch,然后立即使用svn rebase (如果只fetch的不rebase的话,查看日志的时候,是看不到fetch下来的代码的)
新增说明: git svn clone结束的时候,会自动压缩文件,但是压缩会失败。 所以在git svn clone,开始一小会之后,可以ctrl+c打断命令的执行。
然后修改.git文件夹下的config文件 在 [core] 下面新增两行,主要是用来限制压缩文件的大小的 packedGitLimit = 128m packedGitWindowSize = 128m
再添加以下代码 [pack] deltaCacheSize = 128m packSizeLimit = 128m windowMemory = 128m
另外有时候git svn fetch执行会卡住,有可能是内存不足的原因。切换到git bash执行此命令,并且关闭其他所有程序。确保git可以拉取svn的代码。之后不要忘记svn rebase
在git svn clone的时候直接同步分支以及Tag -T -b -t参数
git svn clone file:///tmp/test-svn -T trunk -b branches -t tags
http://stackoverflow.com/questions/3239759/checkout-remote-branch-using-git-svn 从svn的服务器拉取完整代码以及切换分支的方法
Create a git clone of that includes your Subversion trunk, tags, and branches with
git svn clone http://svn.example.com/project -T trunk -b branches -t tags
The --stdlayout
option is a nice shortcut if your Subversion repository uses the typical structure:
git svn clone http://svn.example.com/project --stdlayout
Make your git repository ignore everything the subversion repo does:
git svn show-ignore >> .git/info/exclude
You should now be able to see all the Subversion branches on the git side:
git branch -r
Say the name of the branch in Subversion is waldo
. On the git side, you'd run
git checkout -b waldo-svn remotes/waldo
The -svn suffix is to avoid warnings of the form
warning: refname 'waldo' is ambiguous.
To update the git branch waldo-svn
, run
git checkout waldo-svn git svn rebase
To add a Subversion branch to a trunk-only clone, modify your git repository's .git/config
to contain
[svn-remote "svn-mybranch"] url = http://svn.example.com/project/branches/mybranch fetch = :refs/remotes/mybranch
You'll need to develop the habit of running
git svn fetch --fetch-all
to update all of what git svn
thinks are separate remotes. At this point, you can create and track branches as above. For example, to create a git branch that corresponds to mybranch, run
git checkout -b mybranch-svn remotes/mybranch
For the branches from which you intend to git svn dcommit
, keep their histories linear!
You may also be interested in reading an answer to a related question.