Gitã¨Subversionãä½µç¨ãã
ä»äºã§ã¯Subversionï¼ä»¥ä¸ãsvnï¼ã使ã£ã¦ããã®ã ãããããgitã«ç½®ãæãããã
ã¨ã¯ããããããªãå
¨ä½ãgitã«ç§»è¡ããã®ã¯ãããããªã®ã§ã以ä¸ã®ãããªããã»ã¹ãè¸ããã¨æãã
(1) èªåã®ç°å¢ã ãgitã使ããããã«ããï¼ä¸å¤®ãªãã¸ããªã¯svnï¼
(2) ä»ã®ã¡ã³ãã¼ï¼æ°åè¦æ¨¡ï¼ãgitã使ããããã«ããï¼ä¸å¤®ãªãã¸ããªã¯svnï¼
(3) ä¸å¤®ãªãã¸ããªãsvnããgitã«å¤ãã
ãã®ã¨ã³ããªã§ã¯ä¸è¨(1)ã®çµç·¯ãæ¸ãã¨ãã¦ããã
ç¾ç¶
ã»ä»¥ä¸ã®ããã«ä¸å¤®ã«svnãªãã¸ããªãåå¨ãã¦ãã¦ãå人ããããããã§ãã¯ã¢ã¦ããã¦ãã
ã»å人ã¯ãã§ãã¯ã¢ã¦ããããsvnä½æ¥ã³ãã¼ããããä½æ¥ç¨ãã£ã¬ã¯ããªãã«ã³ãã¼ãã¦ããï¼cpãrsyncã§ï¼
ã»å人ã®ãä½æ¥ç¨ãã£ã¬ã¯ããªãã®htdocsã¯devç°å¢ã¨ãã¦ãã©ã¦ã¶ããé²è¦§å¯è½
ã»å人ã®ãsvnä½æ¥ã³ãã¼ãã¨ãä½æ¥ç¨ãã£ã¬ã¯ããªãã¯ä¸è´ããªãï¼ãã¼ã¸ã§ã³ç®¡çããªããã¡ã¤ã«ã沢山ããï¼
ã»å人ã®ãsvnä½æ¥ã³ãã¼ãã¨ãä½æ¥ç¨ãã£ã¬ã¯ããªãã®å·®å管çãã¨ã«ãã大å¤ãªç¶æ³
èªåã®ç°å¢ã ãã§ãgitã«ãããããããæ¹æ³ã¨ãã¦ä»¥ä¸ã®3ã¤ãæãã¤ããã®ã§ããããã試ãã¦ã¿ãã
æçµçã«ã(C) git-svnã使ãããã¨ã«ãªã£ãã®ã ããæè§ãªã®ã§ããã¾ã§ã®çµç·¯ãè¨é²ãã¦ããã
(A) ãsvnä½æ¥ã³ãã¼ãããgitãªã¢ã¼ããªãã¸ããªãã¨ãã¦ä½¿ã
以ä¸ã®ããã«svnä½æ¥ã³ãã¼ãgitãªã¢ã¼ããªãã¸ããªï¼bareã§ã¯ãªãã¯ã¼ãã³ã°ããªã¼ãæã¤ãªãã¸ããªï¼ã«ãã¦ãgitãã¼ã«ã«ãªãã¸ããªããpull/pushããå½¢ãèããã
çµæ: ä¸æ¡ç¨
çç±: gitã®ãªã¢ã¼ããªãã¸ããªã¯åºæ¬çã«bareãªãã¸ããªã§ãããã¨ãæ¨å¥¨ãããããã
# svnãªãã¸ããªãããã§ãã¯ã¢ã¦ããã¦svnä½æ¥ã³ãã¼ãä½ã $ svn checkout [svnãªãã¸ããª] [svnä½æ¥ã³ãã¼] # svnä½æ¥ã³ãã¼ãgit管çä¸ã«ããï¼gitãªã¢ã¼ããªãã¸ããªãå ¼ä»»ãããï¼ $ cd [svnä½æ¥ã³ãã¼ã®ããã] $ git init # svnã®ç®¡çä¸ãã.gitã¨.gitignoreãé¤å» # â»è¨å®ç¨ã®ã¨ãã£ã¿ã«ã¯vimã使ç¨ãã # â»åè: http://log.xinu.jp/2011-07-25-1.html $ export svn_EDITOR="vim" $ svn propedit svn:ignore ./ .git .gitignore # ç¢ºèª $ svn status $ svn status --no-ignore # gitã®ç®¡çä¸ãã.svnãé¤å» $ vim .gitignore .svn # ç¢ºèª $ git status # gitã«ã³ããããã $ git add . $ git commit -m 'init' # ä½æ¥ãã£ã¬ã¯ããªï¼gitãã¼ã«ã«ãªãã¸ããªï¼ã«ç§»åã # svnä½æ¥ã³ãã¼ï¼gitãªã¢ã¼ããªãã¸ããªï¼ããcloneãã $ cd [ä½æ¥ãã£ã¬ã¯ããª|gitãã¼ã«ã«ãªãã¸ããª] $ git clone [svnä½æ¥ã³ãã¼|gitãªã¢ã¼ããªãã¸ããª] # ãªãããã®ãã¡ã¤ã«ã«å¤æ´ãå ããå¾ãpushãã $ git add . $ git commit -m 'test' $ git push # ã¨ã©ã¼ãåºãï¼ ï¼ç¥ï¼ remote: error: refusing to update checked out branch: refs/heads/master remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match remote: error: the work tree to HEAD. remote: error: remote: error: You can set 'receive.denyCurrentBranch' configuration variable to remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into remote: error: its current branch; however, this is not recommended unless you remote: error: arranged to update its work tree to match what you pushed in some remote: error: other way. remote: error: remote: error: To squelch this message and still keep the default behaviour, set remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. ï¼ç¥ï¼
(B) ãsvnä½æ¥ã³ãã¼ãããgitãã¼ã«ã«ãªãã¸ããªãã¨ãã¦ä½¿ã
以ä¸ã®ããã«svnä½æ¥ã³ãã¼ãgitãã¼ã«ã«ãªãã¸ããªã¨ãã¦ä½¿ãæ§æãèããã
gitãªã¢ã¼ããªãã¸ããªãå¥éç¨æãã¦ããããä¸éå°ç¹ã¨ãã¦pull/pushãããããªæ§æã
çµæ: ä¸æ¡ç¨
çç±: ä¸å¿ã§ããããä½åº¦ãpushãpullãããå¿
è¦ããã£ã¦é¢åãã¾ãè¤éãªã®ã§ãã¹ãå¤ããªãããã
# >>> ãããã $ svn checkout file:hoge fuge $ cd [svnä½æ¥ã³ãã¼ã®ããã] $ git init $ export svn_EDITOR="vim" $ svn propedit svn:ignore ./ .git .gitignore $ vim .gitignore .svn $ git add . $ git commit -m 'init' # <<< ããã¾ã§ã¯1.ã¨åã # gitã®bareãªãã¸ããªãä½ã $ mkdir [git_bareãªãã¸ããªã®] $ cd [git_bareãªãã¸ããª] $ git clone --bare [svnä½æ¥ã³ãã¼] # svnä½æ¥ã³ãã¼ã«ç§»åããä½æããgitã®bareãªãã¸ããªãgitãªã¢ã¼ããªãã¸ããªã«è¨å®ãã $ cd [svnä½æ¥ã³ãã¼] $ git remote add [ãªã¢ã¼ããªãã¸ããªå] [git_bareãªãã¸ããª] # ä½æ¥ç¨ã®ãã£ã¬ã¯ããªã«cloneãã $ cd [ä½æ¥ç¨ãã£ã¬ã¯ããª] $ git clone [git_bareãªãã¸ããª] # ä½æ¥ç¨ãã£ã¬ã¯ããªã§ãªãããã®ãã¡ã¤ã«ã«å¤æ´ãå ããå¾ãpushãã $ git add . $ git commit -m 'test' $ git push # svnä½æ¥ã³ãã¼ã§git pull $ cd [svnä½æ¥ã³ãã¼] $ git pull # svnã®ç¶æ ãç¢ºèª $ svn status -u
(C) git-svnã使ã
çµæã¨ãã¦å®ç³éãã«ãããæ¡ç¨ããã
èªåã®ç°å¢ã§ã®åé¡ã¯ãgit管çä¸ã«ãããããªããã¡ã¤ã«ãç°å¸¸ã«æ²¢å±±ãããã¨ã
ããã§.gitignoreãã¡ã¤ã«ãããªãä¸å¯§ã«æå®ããã
.gitignoreã®æå®æ¹æ³ã«ã«ã¤ãã¦ã¯こちらのエントリã«ã¾ã¨ããã
ã¾ãã以ä¸ã®ãµã¤ããåèã«ãã¦ä½æ¥ããã
git svn cloneをやるときは--prefix svn/をつけるべき - DQNEO起業日記
Git - Git と Subversion
# ç¾å¨ã®ä½æ¥ç¨ãã£ã¬ã¯ããªããã£ããéé¿ $ mv [ä½æ¥ç¨ãã£ã¬ã¯ããª] [æ§ä½æ¥ãã£ã¬ã¯ããª] # æ°ããä½æ¥ç¨ãã£ã¬ã¯ããªãä½æããgit管çä¸ã« $ mkdir [æ°ä½æ¥ç¨ãã£ã¬ã¯ããª] $ cd [æ°ä½æ¥ç¨ãã£ã¬ã¯ããª] $ git init # git-svnãã¤ã³ã¹ãã¼ã«ããã¦ããã確èªããªããã°ã¤ã³ã¹ãã¼ã« $ git svn --version # subversionã®ãªãã¸ããªãåãè¾¼ã # ï¼æ³¨æï¼ï¼éå»ã®ã³ãããæ°ãå¤ãã¨ãæ»ã¬ã»ã©æéããããå ´åãããï¼æ°æ¥ãããå ´åããããããï¼ã®ã§æ³¨æ # èªåã®ç°å¢ã§ã¯ã1000ã³ãããããããããªãã¸ããªã15åãããã ã£ã $ git svn clone -s --prefix svn/ [svnãªãã¸ããªï¼trunkã¯ã¤ããªãï¼] [cloneå¾ãã£ã¬ã¯ããªå] # svnãªãã¸ããªã®æ å ±ç¢ºèª # svnãªãã¸ããªã®ãã°ç¢ºèª $ git svn info $ git svn log # .gitignoreãç´°ããæå® $ vim .gitignore è²ã ãªè¨å® # æ§ä½æ¥ç¨ãã£ã¬ã¯ããªãæ°ä½æ¥ç¨ãã£ã¬ã¯ããªã«ä¸æ¸ã $ cp -R [æ§ä½æ¥ç¨ãã£ã¬ã¯ããªã®å 容] [æ°ä½æ¥ç¨ãã£ã¬ã¯ããª] # ç¢ºèª git status
å®éç¨
ãã¡ãã®ããã°ã«æ²è¼ããã¦ããå
容ã大å¤åèã«ãªãã¾ããã
git-svnを使うときのベストプラクティス - Life goes on
git-svnの使い方を覚えた - idesaku blog
ä»å¾
å人ããã¼ã«ã«ç°å¢ã§gitã«æ £ããããªã¢ã¼ããªãã¸ããªèªä½ãsvnããgitã«ç§»ç®¡ããã