1、從svn clone出項目,加上-s參數(shù)以標(biāo)記識別svn標(biāo)準(zhǔn)的目錄分支結(jié)構(gòu),同時通過show-ignore設(shè)置git庫的exclude屬性:
- git svn clone -s https://svn.xxx.com/svn/xxx
- git svn show-ignore >> .git/info/exclude
2、建立本地工作分支,開始工作:
- git checkout -b work
修改內(nèi)容直接commit,加上-a開頭以省略git add操作:
- git commit -a
3、提交回svn的過程:
- 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時在master分支上產(chǎn)生了一個新的node,這樣merge時就不能快速合并,出現(xiàn)了沖突,修復(fù)后,在dcommit時出錯,出現(xiàn)N個孤立節(jié)點。因為不熟悉,就checkout出work分支,進行了dcommit,然后重新生成一次git庫。
今天解決了這個問題,參考以下網(wǎng)址:https://wiki.bnl.gov/dayabay/index.php?title=Synchronizing_Repositories。
以下重新描述一下問題和解決方法:
1、在執(zhí)行g(shù)it svn dcommit時,出現(xiàn)如下錯誤:
Committing to https://svn.xxx.com/svn/projects/trunk ...
提交時發(fā)生合并沖突: 您的文件或目錄”test/functional/xxx_controller_test.rb“可能已經(jīng)過時: 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、這時,重新執(zhí)行以下步驟即可:
- git svn fetch
- git svn rebase
- git svn dcommit
但我在執(zhí)行g(shù)it svn rebase時,又出現(xiàn)沖突,這個時候,只需要手工合并掉沖突,并重新add一下:
- git add .
然后,再執(zhí)行:
- git rebase --continue
如果報告說沒有修改內(nèi)容,則換成執(zhí)行:
- git rebase --skip
完成rebase過程,這時就可以git svn dcommit了。
這樣,總算解決了svn歷史沖突問題,不用象前面那樣笨笨的重新git-svn clone.
***************************************************************************************************
***************************************************************************************************
git是源于linux內(nèi)核源碼的管理,自然更適合在linux系統(tǒng)下使用。
在windows環(huán)境下,主要有2種方式:msysgit和cygwin內(nèi)置的git(需要選擇安裝)。
個人建議使用cygwin git,msysgit的編碼問題確實讓人頭痛。
當(dāng)然,如果要使用圖形工具Tortoisegit,就必須安裝msysgit了。
cygwin配置:
(1)在/etc/profile末尾加上一行:. "$HOME/.bashrc"
(2)在$HOME目錄下新建.bashrc文件,寫入一行: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)
建立臨時分支:git branch aaa
切換到臨時分支:git checkout aaa
提交:git add .
提交確認:git commit
提交及確認:git commit -a (git add . + git commit,但新增文件必須要git add .)
切換回master分支:git checkout master
合并臨時分支:git merge aaa
刪除臨時分支: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
如果報告說沒有修改內(nèi)容,則換成執(zhí)行:
git rebase --skip

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