git/svn 使ãã¯ããã¦ã¿ã
以åããZIGOROuããããgitãã¿ã®ããã°æ¸ããªãã¨è¨ããã¦ããã®ã§ãéãè °ãä¸ãã¦æ¸ãå§ãããã¨æãã
ä½ã¯ã¨ãããSubversionãããªãã¸ããªãåå¾ããã
cd ~/work git svn clone http://centos5/git-test -T trunk -b branches -t tags
ã-Tããã-bããã-tããªãã·ã§ã³ã¯æå®ããªãã¦ãããããæå®ãã¦ããã¨gitãªãã¸ããªä½ææã«ãªã¢ã¼ã追跡ãã©ã³ããèªåçã«è¨å®ãã¦ãããã®ã§æå®ãã¦ããã
git branch -r ã§ãªã¢ã¼ã追跡ãã©ã³ãã®ä¸è¦§ã表示ãããã
cd ~/work/git-test git branch -r stable-1.0 tags/release-1.0 trunk
ã-rããªãã·ã§ã³ãªãã§ç¾å¨ã®ãã©ã³ãä¸è¦§ã表示ãããããmasterãã¯gitãããã©ã«ãã§ä½æãããã©ã³ãã
git branch * master
.git/HEAD ã®ä¸èº«ãè¦ããã¨ã§ç¾å¨ã®ãã©ã³ãã確èªãããã¨ãã§ããã
cat .git/HEAD ref: refs/heads/master
git checkout -b (æ°ãããã©ã³ãå) (èªã¿è¾¼ããã©ã³ãå) ã§gitãªãã¸ããªãããªã¢ã¼ã追跡ãã©ã³ã stable-1.0 ã®HEADããã§ãã¯ã¢ã¦ããã¦æ°ãããã©ã³ã stable-1.0 ãä½æãã¦ããããåãæ¿ããè¡ã£ã¦ãããã
ã-bããªãã·ã§ã³ã¯gitãªãã¸ããªã«æ°ãããã©ã³ããä½ãã¨ãã«ã®ã¿ä½¿ç¨ããã
git checkout -b stable-1.0 stable-1.0 git branch master * stable-1.0
å½ç¶ .git/HEAD ã®ä¸èº«ãåãæ¿ãã£ã¦ããã
cat .git/HEAD ref: refs/heads/stable-1.0
æ¢ã«åå¨ãããã©ã³ãã®åãæ¿ãã¯ã-bããªãã·ã§ã³ãªãã§åã« git checkout **** ã§OKã
git checkout master cat .git/HEAD ref: refs/heads/master
ã§ã¯å®éã«ç·¨éããå 容ãgitãªãã¸ããªãsvnãªãã¸ããªã«ã³ããããã¦ã¿ããã¨ããã®åã«ã³ãããæã«èãããååã¨ã¡ã¼ã«ã¢ãã¬ã¹ãç»é²ãã¦ããã
git config user.name typomaster git config user.email [email protected]
ã§ã¯ãå®éã«ç·¨éãã¦å·®åã確èªããªããgitãªãã¸ããªã¾ã§ã³ããããã¦ã¿ãã
vi hoge aaa 111 <- 追å
vi dir/fuga bbb 222 <- 追å
git diff diff --git a/dir/fuga b/dir/fuga index f761ec1..0f4bdea 100644 --- a/dir/fuga +++ b/dir/fuga @@ -1 +1,2 @@ bbb +222 diff --git a/hoge b/hoge index 72943a1..7466234 100644 --- a/hoge +++ b/hoge @@ -1 +1,2 @@ aaa +111
git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # # modified: dir/fuga # modified: hoge # no changes added to commit (use "git add" and/or "git commit -a")
æå¾ éãå·®åã確èªã§ããã®ã§gitãªãã¸ããªã« add & commit ããã
git add . git diff (ä½ã表示ãããªã)
git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: dir/fuga # modified: hoge
git commit (ã³ãããã¡ãã»ã¼ã¸ãå ¥åãã)
以ä¸ã§gitãªãã¸ããªã¸ã®ã³ãããã¯å®äºãgit add . 㨠git commit ã¯ã¾ã¨ã㦠git commit -a ã§å®è¡ã§ããã
念ã®ããã³ããããããå·®åã確èªãã¦ã¿ãã
git show HEAD commit a27965bda41d4951e5f7496f7512c9c9270508d6 Author: typomaster <[email protected]> Date: Mon Mar 16 05:02:50 2009 +0900 git test commit. diff --git a/dir/fuga b/dir/fuga index f761ec1..0f4bdea 100644 --- a/dir/fuga +++ b/dir/fuga @@ -1 +1,2 @@ bbb +222 diff --git a/hoge b/hoge index 72943a1..7466234 100644 --- a/hoge +++ b/hoge @@ -1 +1,2 @@ aaa +111
ãã1ã¤åã®ã³ãããã確èªããã«ã¯
git show HEAD^ commit ffdaa21c91faf6eb259b0b49b7bba0c140fd29cb Author: typomaster <typomaster@3076b008-3b7a-4d17-b439-d3a6704986cd> Date: Sun Mar 15 08:17:35 2009 +0000 test commit. git-svn-id: http://centos5/git-test/tags/release-1.0@6 3076b008-3b7a-4d17-
ã§ç¢ºèªã§ããã2åå㯠git show HEAD^^, 5åå㯠git show HEAD~5 ã§ç¢ºèªã§ããã
ã§ã¯ç¶ãã¦ä»ã³ããããããã®ãsvnãªãã¸ããªã«ã³ããããã¦ã¿ããã¨ãã®åã«svnãªãã¸ããªã§æ´æ°ããããããããªãã®ã§ããããåå¾ãã¦ãã¼ã¸ããã
git svn fetch M foo r7 = c847b24de53d91041bbcb1589b89d65125557404 (trunk)
trunk ã«å¤æ´ããã£ãã¿ãããgitãªãã¸ããªã®ãªã¢ã¼ã追跡ãã©ã³ãã®trunkã«åãè¾¼ãããå·®åã確èªãã¦ã¿ãã
git diff trunk diff --git a/foo b/foo index f812144..1d60b70 100644 --- a/foo +++ b/foo @@ -1,2 +1 @@ ccc -ZZZ
確ãã«å·®åã確èªã§ãããmasterãã©ã³ãã«å·®åãåãè¾¼ãã
git rebase trunk First, rewinding head to replay your work on top of it... HEAD is now at c847b24... svn commit. Applying work git test commit. Wrote tree 39994fc850b22ec09c4f29b25c0dd4c6d59a2eaf Committed: 29548eca23086c67dcd774921e0308faab51080e
æ¬å½ã«åãè¾¼ãããå¤æ´ãããã¡ã¤ã«ãè¦ã¦ã¿ãã
cat foo ccc ZZZ
ã¡ããã¨å¤æ´ãmasterãã©ã³ãã«åãè¾¼ãã¦ããããã¨ã¯gitãªãã¸ããªã®å·®åãsvnãªãã¸ããªã«ãã³ãããããã
git svn dcommit M dir/fuga M hoge Committed r9 M hoge M dir/fuga r9 = c22116dfe457a8b4ead40690e3c832016ba9deb6 (trunk) W: HEAD and refs/remotes/trunk differ, using rebase: :040000 040000 f7de5d9a1d86a2ec2812e3f3bcdce0f17c5aa59f 8b6aa1e01e5f41dbada079881370c1f3d9185c62 M dirFirst, rewinding head to replay your work on top of it... HEAD is now at c22116d... work2 git test commit. Nothing to do.
å®éã«svnãªãã¸ããªã«ã³ããããããã確èªãããã¾ãgitãªãã¸ããªã§å·®åããªããã確èªããã
git diff trunk (ä½ã表示ãããªã)
git log commit c22116dfe457a8b4ead40690e3c832016ba9deb6 Author: typomaster <typomaster@3076b008-3b7a-4d17-b439-d3a6704986cd> Date: Sun Mar 15 13:03:27 2009 +0000 work git test commit. git-svn-id: http://centos5/git-test/trunk@9 3076b008-3b7a-4d17-b439-d3a670
git svn log r9 | typomaster | 2009-03-15 22:03:27 +0900 (æ¥, 15 3æ 2009) | 2 lines work git test commit.
svnãªãã¸ããªã®ä½æ¥ã³ãã¼ã§å·®åãåå¾ãã¦ã¿ãã
svn st -u * 3 dir/fuga * 2 hoge ç¶æ ã®èæ¯ã¨ãªããªãã¸ã§ã³: 9
svn up U dir/fuga U hoge ãªãã¸ã§ã³ 9 ã«æ´æ°ãã¾ããã
cat hoge aaa 111
cat dir/fuga bbb 222
確ãã«svnãªãã¸ããªã«ãå¤æ´ãåæ ããã¦ããã
git/svn ã®åºæ¬çãªä½¿ãæ¹ã®è©±ãªã®ã«ãããªã«é·ããªã£ã¦ãã¾ã£ãããããã¶ãããã°æ¸ãã®ã«æ £ãã¦ãªãããã
ãã£ã¨ãæ¬å½ã«åºæ¬ã®åºæ¬ã ããæ¸ããã®ã§æ¬¡åã¯ã³ã³ããªã¯ããèµ·ããã¨ãã®ãã¼ã¸ã®ä»æ¹ãæ¸ããã¨æãã