​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的服务器拉取完整代码以及切换分支的方法


Standard Subversion layout

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


Starting from a trunk-only checkout

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!



Further information

You may also be interested in reading an ​​answer to a related question​​.

 

 

 

===2015年09月27日更新===

git详解之八 git与其他系统  ​​http://www.open-open.com/lib/view/open1328070454218.html​

Git-Svn 总结

​git svn​​ 工具集在当前不得不使用 Subversion 服务器或者开发环境要求使用 Subversion 服务器的时候格外有用。不妨把它看成一个跛脚的 Git,然而,你还是有可能在转换过程中碰到一些困惑你和合作者们的迷题。为了避免麻烦,试着遵守如下守则:

  • 保持一个不包含由 ​​git merge​​ 生成的 commit 的线性提交历史。将在主线分支外进行的开发通通衍合Rebase回主线;避免直接合并。
  • 不要单独建立和使用一个 Git 服务来搞合作。可以为了加速新开发者的克隆进程建立一个,但是不要向它提供任何不包含 ​​git-svn-id​​ 条目的内容。甚至可以添加一个​​pre-receive​​ 挂钩来在每一个提交信息中查找 ​​git-svn-id​​并拒绝提交那些不包含它的 commit。

如果遵循这些守则,在 Subversion 上工作还可以接受。然而,如果能迁徙到真正的 Git 服务器,则能为团队带来更多好处。

建立2个分支,一个叫svn,另外一个叫local

svn分支,就是上面说的主线分支,[用于和svn服务器同步]

在local上进行代码开发,开发完成以后,按照以下步骤处理

 

1.首先切换到 svn分支,git svn rebase更新服务器上的svn代码

 

这时,会有2种情况

情况1

svn服务器上没有更新代码,那么此时,只要把local分支的修改,直接fast forward合并到svn分支就可以了

 

情况2

svn服务器上更新了代码,那么同步代码之后,就要local分支上的代码弄到svn分支上

(1)切换到local分支,git rebase svn

处理完之后,local分支看起来就像是在svn分支上直接开发的一样     【其实这里也可以直接git svn dcommit,然后切换到svn分支,再同步代码。最后再切回local分支继续开发】

(2)然后切换到svn分支,git merge local进行快速合并

(3)最后,在svn分支上,git svn dcommit

 

 

 

 

git svn_git

local分支做了一次最新的提交

svn分支使用git svn rebase同步了svn服务器上的代码

现在需要切换到local分支,然后使用git rebase svn;使得local的开发,看起来像是直接从svn分支的最后一个commit开始

 

右键菜单,tortoisegit-->rebase

git svn_svn服务器_02

 

出现冲突需要处理,local的指向暂时没有改变。但是working dir changes

 git svn_git_03

 

 

 

同时维护svn和git的策略:

优先向svn服务器进行git svn dcommit

然后才可以向git服务器进行git push,否则会导致git和svn不在一条直线上

 

 

 如何查看svn版本库对应的信息

git svn info

Path: .

URL: https://server2008/svn/ZBMSH/Hardware/zbm_core_fpga/trunk/Software/ZBM%20St

udio

Repository Root: https://server2008/svn/ZBMSH

Repository UUID: fa437c58-89a3-0d4c-9098-8bc72d4331b5

Revision: 2653

Node Kind: directory

Schedule: normal

Last Changed Author: lujuntaozbm

Last Changed Rev: 2653

Last Changed Date: 2016-05-18 14:43:47 +0800 (Wed, 18 May 2016)

 

 

 

2016年07月29日

C:\Program Files (x86)\Git\etc\gitconfig

svn的中文路径的支持设置

[svn]

pathnameencoding = utf-8

 

​https://gitlab.com/tortoisegit/tortoisegit/issues/2811​

The svn-remote has no fetch entry. TortoiseGit requires it. 

 

$ git svn init -s https://server2008/svn/ZBMSH/Hardware/Software/zbm_studio/trunks --prefix=origin/

Initialized empty Git repository in D:/Hardware/Test/.git/

Using higher level of URL: https://server2008/svn/ZBMSH/Hardware/Software/zbm_studio/trunks => https://server2008/svn/ZBMSH/Hardware/Software/zbm_studio

 

 关于svn地址的获取,不要从浏览器获取。否则从浏览器中获取的url是错误的。

例如

在tortoisesvn中查看的地址是http://172.31.212.138/svn/LISA/05.releases/LISA_5.0.0.0/beta   

但是浏览器中最终转换成了http://172.31.212.138/!/#LISA/view/head/05.releases/LISA_5.0.0.0/beta