項目開發過程中總有一些奇奇怪怪的需求出現。
我們的項目管理是使用SVN的,用SVN是歷史原因,無法整個項目向Git切換。由於我需要管理SVN,做一些代碼合並工作。每次合並都會遇到SVN代碼需要對比查看,檢查代碼。經常也需要自己對他們的代碼做一些優化。中間優化版本也無法提交,優化多了也可能導致代碼出錯,感覺整個人都不好了。
所以現在使用SVN+Git協同工作的方式,感覺整個人都好多了。
方法:
先在svn目錄中增加ignore屬性
舉例:svn/trunk/example目錄
cd svn/trunk/example svn propedit svn:ignore ./ 打開了edit界面 .git .gitignore 保存退出
通過編輯svn的svn:ginore屬性,讓其忽略git管理所用的目錄
在svn/trunk/example目錄中,創建git倉
cd svn/trunk/example git init git co -b svn git add * git commit -m "Git init, the save version as svn-rxxxx"
這樣,就可以有一個本地git存在了。
Git倉也可以有遠程倉,遠程倉的創建命令如下:
git init --bare svn-repo pushd svn-repos cd hooks cp post-update.simple post-update popd
使用ssh協議,將svn項目托管到遠程倉上,
cd svn/trunk/example git remote add origin git@git-server:~/svn-repo git push origin svn:svn
由於使用了ssh協議,在此假定ssh目的服務器的用戶名為git,服務器名為git-server(也可以用ip)。
通過以上操作,example已經同時托管在了svn和git上。這樣就可以使SVN只做穩定版本存放服務器了。