é·å¹Žã«ããã£ãŠãSVNã®ã¿ãå€æ°ã®ãããžã§ã¯ãã®ããŒãžã§ã³ç®¡çã·ã¹ãã ãšããŠäœ¿çšãããŠããŸããã ãããããããžã§ã¯ãã®1人ã®éçºè ã®æ°ãèããå¢å ãããããžã§ã¯ãããã§ã«éå§ãããŠãããããã€ãã®æ©èœã䞊è¡ããŠç©æ¥µçã«éçºããæ¢åã®ãã°ããªã³ã©ã€ã³ã§ä¿®æ£ããå¿ èŠããããŸããã SVNã®åäžã®ãã©ã³ã¯ã§ã¯ãããèš±å¯ãããããã©ã³ãå ã®ãã©ã³ãã®ç·šæã«ãããéçºè ã®ç掻ãå°çã«å€ãããŸãã ãããã£ãŠããã®ãããžã§ã¯ããSVNããGitã«ç§»è¡ããããšã決å®ãããŸããã
1.äžå€®ãªããžããªçšã®ãµãŒããŒ
Gitã¯åæ£ã·ã¹ãã ã§ãããšããäºå®ã«ããããããããã¹ãŠã®éçºè ãæçµçã«åæãããããããã¹ããã«ããå±éãããéçšå±éãå®è¡ãããäžå€®ãªããžããªã®å¿ èŠæ§ãæé€ããŸããã ãããã£ãŠãäž»ã«ãµãŒããŒãå¿ èŠã§ãã ãããžã§ã¯ãã¯åçšã§ãããããã©ãããããããœãŒã¹ãã¡ã€ã«ãå€éšãµãŒããŒã«ä¿åããããªãã£ãã®ã§ãgitãªããžããªãä¿åããã«ã¯ãµãŒããŒãäžããå¿ èŠããããŸãã ãµãŒããŒèªäœã¯Gentooã§å®è¡ããããããå¿ èŠãªãœãããŠã§ã¢ããã¹ãŠã€ã³ã¹ããŒã«ããå¿ èŠããããŸãã
ããã§ã¯ãéžæã¯ç¹ã«å€§ãããããŸãã-gitosisãŸãã¯gitoliteã gitosisã¯æ°å¹ŽåããéçºãããŠããªãã®ã§ãéžæã¯gitoliteã«èœã¡ãŸããã
1.1ã Gitoliteã®ã€ã³ã¹ããŒã«
ãµãŒããŒã«gitolite 3.03ãé 眮ããŸãã
$ emerge gitolite
ããã«ãããå°æ¥ã®ãã¹ãŠã®ãªããžããªãææããgitãŠãŒã¶ãŒãäœæãããŸãã
1.2ã åæèšå®
ããã§ã管çãªããžããªïŒgitoliteã¯ãã¹ãŠã®èšå®ãgitãªããžããªã«ä¿åããïŒã«ã¢ã¯ã»ã¹ããããã®rsaããŒãçæããå ¬éããŒãå ¬éå Žæã«ä¿åããå¿ èŠããããŸãã
$ ssh-keygen -t rsa $ cp ~/.ssh/id_rsa.pub /tmp/admin.pub
ãã®åŸãå®éã«gitoliteãåæåã§ããŸãïŒ
$ su git $ cd $ mkdir -p bin $ gitolite/install -ln $ gitolite setup -pk /tmp/admin.pub
1.3ã ãããžã§ã¯ãã®ãªããžããªãäœæãã
ãµãŒããŒãã€ã³ã¹ããŒã«ããããŠãŒã¶ãŒã«æ»ããæ§æã䜿çšããŠãªããžããªã®ã¯ããŒã³ãäœæããŸãã
$ cd $ git clone git@server:gitolite-admin.git
以äžãserverã¯gitoliteãã€ã³ã¹ããŒã«ããããªããžããªãä¿åããããµãŒããŒã®ãã¹ãåã§ãã
衚瀺ãããgitolite-admin / conf / gitolite.confãã¡ã€ã«ãéãããããžã§ã¯ãã®ãªããžããªã®èª¬æãæåŸã«è¿œå ããŸãïŒãããŸã§ã«1人ã®ãŠãŒã¶ãŒã®ã¿ïŒã
repo project RW+ = javer
ãã®åŸãå€æŽãä¿åããŸãã gitolite-adminã§ã次ãå®è¡ããŸãã
$ git add . $ git commit -am "Repository for project added" $ git push origin master
gitoliteã¯ãæ§æã«èšè¿°ãããŠããŠãŸã ååšããªããã¹ãŠã®ãªããžããªãèªåçã«åæåããŸãã
ããã§ãgitoliteãã€ã³ã¹ããŒã«ãããæåã«æ§æããããããžã§ã¯ãã®ãªããžããªãäœæãããŸãããå ã«é²ãããšãã§ããŸãã
2. SVNãããããžã§ã¯ããã€ã³ããŒããã
SVNãªããžããªãGitã«çŽæ¥å€æããã«ã¯ã次ã®ã³ãã³ãã䜿çšããŸã
$ git svn clone
ãã®ãããgitã¯perlãµããŒãä»ãã§ã³ã³ãã€ã«ããå¿ èŠããããŸãã
2.1ã ç£æ»å®çŸ©ãéå§
ãããžã§ã¯ããããžã§ã¯ãã¯ãä»ã®å€ãã®ãããžã§ã¯ããšãšãã«SVNãªããžããªã«ãããŸãã ãªããžã§ã³çªå·ã¯ãªããžããªå šäœã暪æããŠãããããsvn logã§ãããžã§ã¯ãã«é¢ä¿ããæåã®ã³ããããèŠã€ãããããèŠããŠããŸãã ããã¯ãæåããå§ãŸããã¹ãŠã®ãªããžã§ã³ãã¹ãã£ã³ãããªãããã«ãã€ã³ããŒããé«éåããããã«å¿ èŠã§ãã ç§ãã¡ã®å Žåãããã¯ãªããžã§ã³19815ã§ãããããäžèšã®ã³ãã³ãã«ãªãã·ã§ã³ãè¿œå ãããŸãã
-r19815:HEAD
2.2ã SVNãŠãŒã¶ãŒãšGitãŠãŒã¶ãŒã®ãããã³ã°
次ã«ãSVNãŠãŒã¶ãŒãå°æ¥ã®GitãŠãŒã¶ãŒãšäžèŽãããŠãã€ã³ããŒãäžã«æ£åžžã«çœ®ãæããããããã«ããå¿ èŠããããŸãã ãããè¡ãã«ã¯ãã©ããã§æ¬¡ã®ã³ã³ãã³ããå«ãäœæè ãã¡ã€ã«ãäœæããŸãã
javer = javer <javer@domain.tld> developer1 = developer1 <developer1@domain.tld> ...
user@domain.tldã¯gitãŠãŒã¶ãŒã®é»åã¡ãŒã«ã§ãïŒgitã§ã¯ãåãŠãŒã¶ãŒã¯ååãšé»åã¡ãŒã«ã§èå¥ãããŸãïŒã
ãããã£ãŠãã€ã³ããŒãã³ãã³ãã«ãªãã·ã§ã³ãè¿œå ãããŸãã
--authors-file=/path/to/authors
2.3ã äžèŠãªãã¡ã€ã«ã®é€å€
ããã«é²ãã§ããŸãã ç§ãã¡ã®ãããžã§ã¯ãã§ã¯ã倧ããªãªããžããªãã¡ã€ã«ã®ã©ã³ãã ã³ãããããããŸããããæ°ãããªããžããªã§ã¯å¿ èŠãããŸããã ããããã€ã³ããŒããããšãã«ããªãã·ã§ã³ãé€å€ã§ããŸãã
--ignore-paths="\.(avi|mov)$"
2.4ã è¿œå ãªãã·ã§ã³
ãŸãããªããžããªã«ã¢ã¯ã»ã¹ããSVNã®ãŠãŒã¶ãŒãå¿ èŠã§ãã
--username javer
å¥ã®ãªãã·ã§ã³--no-metadataãè¿œå ããŸããããã¯ãåã³ã¡ã³ãã®ã³ããããã°ã«ãã©ãŒã ã®è¿œå ããªãããã«ããããã«å¿ èŠã§ãã
git-svn-id: svn://svn.domain.tld/repo/project/trunk@19815 e13dc095-444b-fa4e-8f24-06838a8318a5
ãããžã§ã¯ãã®SVNãªããžããªã§ã¯ãæçšãªæ å ±ã¯ãã©ã³ã¯ã«ã®ã¿ä¿åãããããã€ãã®ãã©ã³ãã«ã¯äžæçãªã³ãŒããå«ãŸããŠããŸããããäžæçãªã³ãŒãã¯ããã§ããã©ã³ã¯ãã掟çãããããå¿ èŠãªããªããŸããã
2.5ã SVNãªããžããªãããããžã§ã¯ããè€è£œãã
ãã¹ãŠããŸãšããŠå®è¡ããïŒ
$ cd $ mkdir project && cd project $ git svn clone -r19815:HEAD --authors-file=/path/to/authors --ignore-paths="\.(avi|mov)$" --username javer --no-metadata svn://svn.domain.tld/repo/project/trunk .
svnïŒ//svn.domain.tld/repo/project/trunkã¯ãSVNãªããžããªå ã®ãããžã§ã¯ãã®ãã©ã³ã¯ã¢ãã¬ã¹ã§ãã
ã¯ããŒã³äœæããã»ã¹ãéå§ãããŸãããã®æéã¯ãã³ãããã®æ°ãšãã®ããªã¥ãŒã ã«ãã£ãŠç°ãªããŸãã ç§ãã¡ã®å ŽåãçŽ4.5å件ã®ã³ããããããããããã®ã¯ããŒã³ãäœæããã®ã«çŽ2æéããããŸããã
2.6ã äžèŠãªãã¡ã€ã«ãšãã£ã¬ã¯ããªã®é€å€
ãããžã§ã¯ããã£ã¬ã¯ããªã§ã®ã¯ããŒã³äœæãå®äºãããšãã³ãããã®å šå±¥æŽãå«ããããžã§ã¯ãã®å®å šãªã¯ããŒã³ãååŸãããŸãã ã¯ããŒã³ãäœæããåŸãããšãã°ãå¥ã®ãªããžããªã§éžæãããããæ°ãããªããžããªã§ã¯äžèŠãªãã£ã¬ã¯ããªãã¯ããŒã³ããããã«èŠããããšããããŸãã 次ã®ããã«ããŠããã£ã¬ã¯ããªãšãã®ãã£ã¬ã¯ããªãžã®ãã¹ãŠã®åç §ãå±¥æŽããåé€ã§ããŸãã
$ git filter-branch --tree-filter 'rm -rf unneeded_directory' -f HEAD
ãŸããåã³ãããã¯åå¥ã«ã¬ãã¥ãŒãããããããã®ããã»ã¹ãéåžžã«é·ããªããŸãããã®å Žåãã³ãããããšã«çŽ1ç§ããããŸããã
2.7ã 空ã®ã³ããããåé€ãã
ãããŸã§ã®ãã¹ãŠã®ã¢ã¯ã·ã§ã³ã®çµæãšããŠãã³ãããã®å šå±¥æŽãå«ãã¯ããŒã³ãããžã§ã¯ããååŸããŸããããã®äžã«ã¯ã空ã®ã³ããããã€ãŸãåäžã®å€æŽããããã¡ã€ã«ã®ãªãã³ãããããããŸãã ãããã¯ãignore-pathsãªãã·ã§ã³ãä»ããäžéšã®ãã¡ã€ã«ã®é€å€ã®çµæããŸãã¯ããªãŒãã£ã«ã¿ãŒãä»ããåŸç¶ã®ãã£ã«ã¿ãªã³ã°ã®çµæãšããŠçŸããŸããã ãã®ãããªç©ºã®ã³ããããåé€ããã«ã¯ã次ã®ããã«ããŸãã
$ git filter-branch --commit-filter 'git_commit_non_empty_tree "$@"' HEAD
ãã®æäœã«ã¯ãããªãŒãã£ã«ã¿ãŒãšã»ãŒåãæéãããããŸãã
2.8ã 空ã®ãã£ã¬ã¯ããªãšsvnïŒç¡èŠ
次ã«ãåã®svnïŒignoreãæ°ãã.gitignoreã«å€æããå¿ èŠããããŸãã ããã¯æ¬¡ã®ããã«è¡ãããŸãã
$ git svn create-ignore
gitã¯ãã£ã¬ã¯ããªã«é¢ããæ å ±ã®ã¿ãä¿åãããã¡ã€ã«ã«é¢ããæ å ±ã®ã¿ãä¿åããããšãå¿ããªãã§ãã ããããã¹ãŠã®ç©ºã®ãã£ã¬ã¯ããªã§ã空ã®.gitignoreãã¡ã€ã«ãäœæãããããã®ãã¡ã€ã«ããã¹ãŠã³ãããããå¿ èŠããããŸãã
$ git add . $ git commit -am "Added .gitignore"
2.9ã SVNã¡ã³ã·ã§ã³ãåé€
ãããžã§ã¯ãã¯SVNããGitã«å®å šã«ç§»è¡ããŠãããããSVNãžã®ãã¹ãŠã®åç §ãåé€ããŸãã
$ git branch -rd git-svn $ git config --remove-section svn-remote.svn $ git config --remove-section svn $ rm -rf .git/svn
2.10ã svnïŒå€èŠ³
ç§ãã¡ã®ãããžã§ã¯ãã§ã¯ãã«ã¹ã¿ã ãšãããªãã¯ã®äž¡æ¹ã®ããã€ãã®symfonyãã©ã°ã€ã³ã¯svnïŒexternalsçµç±ã§æ¥ç¶ãããŸããã gitã«ã¯ãã®ãããªã¡ã«ããºã ããªããããããã«ã¯ãµãã¢ãžã¥ãŒã«ã䜿çšããŸãã å ¬éãã©ã°ã€ã³ã䜿çšãããšãç°¡åã«ãªããŸãã
$ git submodule add git://github.com/propelorm/sfPropelORMPlugin.git plugins/sfPropelORMPlugin $ git submodule add git://github.com/n1k0/npAssetsOptimizerPlugin.git plugins/npAssetsOptimizerPlugin
ãã©ã°ã€ã³ã¯ããå°ãè€éã§ãããã©ã°ã€ã³ã䜿çšããã«ã¯ãäžèšã®ãããªãªããžããªãåå¥ã«äœæããåãæ¹æ³ã§ãããžã§ã¯ãã«æ¥ç¶ããå¿ èŠããããŸãã
$ git submodule add git@server:customPlugin.git plugins/customPlugin
ãµãã¢ãžã¥ãŒã«ãæ¥ç¶ããåŸããããããããžã§ã¯ããã£ã¬ã¯ããªã«è€è£œããå¿ èŠããããŸãã
$ git submodule update --init --recursive $ git commit -am "Added submodules: sfPropelORMPlugin, npAssetsOptimizerPlugin, customPlugin"
2.11ã ãããžã§ã¯ãã®ããŒã«ã«ã³ããŒããµãŒããŒã«éä¿¡ãã
ãã®æäœãé«éåããããã«ãããžã§ã¯ãããµãŒããŒã«éä¿¡ããåã«ããããæé©åããŸãã
$ git gc
æ°ãããªããžããªããããžã§ã¯ãã«æ¥ç¶ããŸãã
$ git remote add origin git@server:project.git
æåŸã«ããµãŒããŒäžã®ãããžã§ã¯ãã®ããŒã«ã«ã³ããŒãå ¥åããŸãã
$ git push origin master
2.12ã ä»åŸã®ãµãã¢ãžã¥ãŒã«ã®æŽæ°
ãªããªããsvnïŒexternalsãšã¯ç°ãªããåãµãã¢ãžã¥ãŒã«ã¯ç¹å®ã®ã³ããããæããããŒã«ã«ã³ããŒã®åçŽãªæŽæ°ãä»ããŠ
$ git pull
ãµãã¢ãžã¥ãŒã«ã®å 容ã¯æŽæ°ãããŸããã æŽæ°å 容ã¯æ¬¡ã®ãšããã§ãã
$ git submodule update
å€æŽããã£ãå ŽåïŒ
$ git submodule foreach git pull $ git commit -am "Updated submodules"
3.ãªããžããªã®ã¢ã¯ã»ã¹èš±å¯ãèšå®ãã
3.1ã ã«ã¹ã¿ã ããŒ
ãªã¢ãŒãgitãªããžããªãžã®ã¢ã¯ã»ã¹ã¯sshçµç±ã§ãããããåéçºè ã¯èªåã®ãã·ã³ã§rsaããŒãçæããå¿ èŠããããŸãã
3.1.1ã Linux / Unix
Linux / UnixãŸãã¯Windowsäžã®Git bashã®å Žåãããã¯æ¬¡ã®ããã«è¡ãããŸãã
$ ssh-keygen -t rsa
ãã®åŸãåä¿¡ããå ¬éããŒã/ .ssh / id_rsa.pubããªããžããªç®¡çè ã«æž¡ãããŸãã
3.1.2ã çª
Windowsã®å Žåã¯ãputtygenã䜿çšããããšãã§ããŸããããã¯ãputtygenããããŠã³ããŒãã§ããŸãã
puttygenãèµ·åãã[çæ]ãã¯ãªãã¯ããŠãããŒãçæããããŸã§ããŠã¹ããŠã£ã³ããŠäžã«ãã©ãã°ããã³ã¡ã³ããã£ãŒã«ãã«ãã®ããŒã®ç®çã瀺ããå¿ èŠã«å¿ããŠããŒã«ã¢ã¯ã»ã¹ããããã®ãã¹ã¯ãŒããå ¥åããŸãã ãã®åŸãå ¬ééµãã£ãŒã«ãã®å 容ãã³ããŒããuser.pubãã¡ã€ã«ã«ä¿åããŠããªããžããªç®¡çè ã«è»¢éããŸãã
次ã«ã[ç§å¯ããŒã®ä¿å]ãã¯ãªãã¯ãããã®ããŒããããšãã°TortoiseGitã§äœ¿çšããããã«äººéé¢ããå Žæã«ä¿åããŸãã
ãŸãã[å€æ]ã¡ãã¥ãŒã§[OpenSSHããŒã®ãšã¯ã¹ããŒã]ãéžæããCïŒ\ Users \ USERNAME \ .ssh \ id_rsaãšãããã¡ã€ã«ã«ä¿åããŸããUSERNAMEã¯ã·ã¹ãã å ã®ãŠãŒã¶ãŒã®ååã§ãã ã³ãã³ãã©ã€ã³ããgitã䜿çšãããšãã«ãã®ããŒãå¿ èŠã«ãªããŸãã
3.2ã æš©éãèšå®ãã
åã®æé ã§ååŸãããŠãŒã¶ãŒå ¬ééµã¯ãUSERNAME.pubãšããååã®ãã¡ã€ã«ã®ã/ gitolite-admin / keydir /ãã£ã¬ã¯ããªã®ç®¡çãªããžããªã«é 眮ãããŸããããã§ãUSERNAMEã¯ãŠãŒã¶ãŒåã§ãã
gitoliteã«ã¯éåžžã«å€ãã®ã«ã¹ã¿ãã€ãºãªãã·ã§ã³ãããããããããã䜿çšããŠãããžã§ã¯ãã®ãªããžããªãžã®ã¢ã¯ã»ã¹æš©ãèšå®ããŸãã ãããè¡ãã«ã¯ããã¡ã€ã«ã/ gitolite-admin / conf / gitolite.confãç·šéãã次ã®åœ¢åŒã«ããŸãïŒ
@owners = javer
@project_developers = user1 user2 user3
@deploy = root@production
repo project
- master$ = @project_developers
- refs/tags = @project_developers
RW+ = @project_developers @owners
R = @deploy
ããã«ãããææè ãŠãŒã¶ãŒã°ã«ãŒããžã®ãã«ã¢ã¯ã»ã¹ãèš±å¯ãããŸãã project_developersã°ã«ãŒãã«ã¯ããã¹ã¿ãŒãã©ã³ããžã®æžã蟌ã¿ãšã¿ã°ã®äœæãé€ããç¬èªã®ãã©ã³ããäœæããæ©èœãåãããã«ã¢ã¯ã»ã¹ããããŸãã å®çšŒåç°å¢ãžã®å±éã«äœ¿çšãããå±éã°ã«ãŒãã§ã¯ãèªã¿åãå°çšã¢ã¯ã»ã¹ãèš±å¯ããŸãã
æåŸã«ããã¹ãŠã®å€æŽãä¿åããããšãå¿ããªãã§ãã ããïŒ
$ git add . $ git commit -am "New users for project: user1, user2, user3..." $ git push origin master
4.éçºè ã®ãã·ã³ã§ã®ã€ã³ã¹ããŒã«ãšæ§æ
ãµãŒããŒéšåã¯å®å šã«æºåãã§ããŠãããéçºãã·ã³ã«gitã¯ã©ã€ã¢ã³ããã€ã³ã¹ããŒã«ããŠæ§æããããšãã§ããŸãã
4.1ã Linux / Unix
ããã§ã¯ãã¹ãŠãç°¡åã§ãããæ°ã«å ¥ãã®ããã±ãŒãžãããŒãžã£ãŒã®å©ããåããŠgitãã€ã³ã¹ããŒã«ããŸãã
ã€ã³ã¹ããŒã«åŸãSVNããã€ã³ããŒããããšãã«äœ¿çšãããã®ãšåãååãšé»åã¡ãŒã«ãæå®ããããšãå¿ããªãã§ãã ããã
$ git config --global user.name "javer" $ git config --global user.email "user@domain.tld"
4.2ã çª
ããã«ã¯ããã€ãã®ç°ãªãã¯ã©ã€ã¢ã³ãããããŸããããããŸã§ã®ãšããTortoiseGitã«æ±ºããŸããã
ãããã€ã³ã¹ããŒã«ããåã«ãç¢æããŒã¿ã«ããããããã æåã« ãã§ããã°ææ°ããŒãžã§ã³ã®msysgitãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãã ã€ã³ã¹ããŒã«äžã«ã·ã¹ãã ãžã®çµ±åã«ã€ããŠå°ããããããGit bashãšã³ãã³ãã©ã€ã³ã®äž¡æ¹ããgitãå®è¡ã§ããããã«ãGit Bashãšã³ãã³ãããã³ãããªãã·ã§ã³ãéžæããããšããå§ãããŸãã
ãã®åŸã TortoiseGitèªäœãã€ã³ã¹ããŒã«ããŸãã ãã€ããªãŒãã«ãã§ã¯ãªããææ°ã®å®å®ããŒãžã§ã³ãã€ã³ã¹ããŒã«ããããšããå§ãããŸãã
TortoiseGitã®èšå®ã«ç§»åãïŒä»»æã®ãã£ã¬ã¯ããªãå³ã¯ãªãã¯ããŠTortoiseGit->èšå®ïŒãããã§Gitã»ã¯ã·ã§ã³ãèŠã€ããå³åŽã®ãŠãŒã¶ãŒæ å ±ãããã¯ã«ååãšé»åã¡ãŒã«ãå ¥åããŸãã
5.移åãå®äºããŸããã ä»äºãå§ãã
以äžã§ãSVNããGitãžã®ç§»è¡ããã»ã¹ã¯å®äºã§ãã
åéçºè ã¯ãããžã§ã¯ããèªåã®è»ã«è€è£œãã圌ãšäžç·ã«äœæ¥ãéå§ããŸãã
éçºè ã«ãããã®èšäºãèªãããšããå§ãããŸãã