1、從svn clone出項(xiàng)目,加上-s參數(shù)以標(biāo)記識(shí)別svn標(biāo)準(zhǔn)的目錄分支結(jié)構(gòu),同時(shí)通過(guò)show-ignore設(shè)置git庫(kù)的exclude屬性:
- git svn clone -s https://svn.xxx.com/svn/xxx
- git svn show-ignore >> .git/info/exclude
2、建立本地工作分支,開(kāi)始工作:
- git checkout -b work
修改內(nèi)容直接commit,加上-a開(kāi)頭以省略git add操作:
- git commit -a
3、提交回svn的過(guò)程:
- git checkout master
- git merge work
- git svn rebase
- git svn dcommit
在今天工作中,我提交回svn的方式是:
- git checkout master
- git svn rebase
- git merge work
結(jié)果svn rebase時(shí)在master分支上產(chǎn)生了一個(gè)新的node,這樣merge時(shí)就不能快速合并,出現(xiàn)了沖突,修復(fù)后,在dcommit時(shí)出錯(cuò),出現(xiàn)N個(gè)孤立節(jié)點(diǎn)。因?yàn)椴皇煜ぃ蚦heckout出work分支,進(jìn)行了dcommit,然后重新生成一次git庫(kù)。
今天解決了這個(gè)問(wèn)題,參考以下網(wǎng)址:https://wiki.bnl.gov/dayabay/index.php?title=Synchronizing_Repositories。
以下重新描述一下問(wèn)題和解決方法:
1、在執(zhí)行g(shù)it svn dcommit時(shí),出現(xiàn)如下錯(cuò)誤:
Committing to https://svn.xxx.com/svn/projects/trunk ...
提交時(shí)發(fā)生合并沖突: 您的文件或目錄”test/functional/xxx_controller_test.rb“可能已經(jīng)過(guò)時(shí): The version resource does not correspond to the resource within the transaction. Either the requested version resource is out of date (needs to be updated), or the requested version resource is newer than the transaction root (restart the commit). at /usr/bin/git-svn line 450
2、這時(shí),重新執(zhí)行以下步驟即可:
- git svn fetch
- git svn rebase
- git svn dcommit
但我在執(zhí)行g(shù)it svn rebase時(shí),又出現(xiàn)沖突,這個(gè)時(shí)候,只需要手工合并掉沖突,并重新add一下:
- git add .
然后,再執(zhí)行:
- git rebase --continue
如果報(bào)告說(shuō)沒(méi)有修改內(nèi)容,則換成執(zhí)行:
- git rebase --skip
完成rebase過(guò)程,這時(shí)就可以git svn dcommit了。
這樣,總算解決了svn歷史沖突問(wèn)題,不用象前面那樣笨笨的重新git-svn clone.
***************************************************************************************************
***************************************************************************************************
git是源于linux內(nèi)核源碼的管理,自然更適合在linux系統(tǒng)下使用。
在windows環(huán)境下,主要有2種方式:msysgit和cygwin內(nèi)置的git(需要選擇安裝)。
個(gè)人建議使用cygwin git,msysgit的編碼問(wèn)題確實(shí)讓人頭痛。
當(dāng)然,如果要使用圖形工具Tortoisegit,就必須安裝msysgit了。
cygwin配置:
(1)在/etc/profile末尾加上一行:. "$HOME/.bashrc"
(2)在$HOME目錄下新建.bashrc文件,寫(xiě)入一行:source /etc/bash-completion.d/git
(3)set CYGWIN=tty notitle glob
set LANG=zh_CN
git及git-svn使用:
下載svn源碼:git svn clone http://xxxx myproject (相當(dāng)于svn checkout)
建立臨時(shí)分支:git branch aaa
切換到臨時(shí)分支:git checkout aaa
提交:git add .
提交確認(rèn):git commit
提交及確認(rèn):git commit -a (git add . + git commit,但新增文件必須要git add .)
切換回master分支:git checkout master
合并臨時(shí)分支:git merge aaa
刪除臨時(shí)分支:git branch -d aaa
從svn更新: git svn rebase (相當(dāng)于svn update)
提交至svn: git svn dcommit (相當(dāng)于svn commit)
查看狀態(tài):git status
查看diff:git diff,git diff head
git svn rebase 沖突:
git add .
然后,再執(zhí)行:
git rebase --continue
如果報(bào)告說(shuō)沒(méi)有修改內(nèi)容,則換成執(zhí)行:
git rebase --skip

posted on 2013-06-04 12:16
聶文龍 閱讀(3731)
評(píng)論(0) 編輯 收藏 引用 所屬分類(lèi):
Linux