ç¸ããã¬ã¤ã§åå¼·ããGitã®åºç¤
ç¸ããã¬ã¤ããããã¨ã§ãGitã®åºç¤ã§ããããã·ã¥ï¼sha-1ï¼ãæèãã¦ã¿ãã
ç¸ããã¬ã¤ ã¨ã¯
1. SMãã¬ã¤ã®ãã¡äºç²ç¸ããªã©ç¸ã使ããã¬ã¤ï¼æ§è¡çºï¼ã®ãã¨ãæåããåå¨ããè¨èã 2. ã²ã¼ã ããã¬ã¤ããéãæ¬æ¥ã²ã¼ã å´ããã¯è¨å®ããã¦ããªãå¶éï¼ç¸ãï¼ãèªãç§ãäºã«ãã£ã¦ãããé£æ度ã®é«ãã²ã¼ã ããã¬ã¤ããäºã
è¨äºã®ã¿ã¤ãã«ã®æå³ã¯ 2. ã®æ¹ã§ãã
æ¦è¦
ç¸ãã®æ¡ä»¶ã¯ä¸è¨ã®éãã
ã¤ã¾ãããªã¢ã¼ãï¼originå«ãï¼ããã©ã³ãï¼masterå«ãï¼ãã¿ã°ã®ä½¿ç¨ç¦æ¢ã§ãã
é¢é£ãã¦ãä¸è¨ã®ã³ãã³ã/æä½ã使ç¨ç¦æ¢ã§ãã
- git clone ï¼origin ãä½æãããããï¼
- git checkout -b ï¼-b ãªãã·ã§ã³ã¯ãã©ã³ãä½ãããã®ã§ç¦æ¢ããã以å¤ã¯OKï¼
- git pull ï¼åä½ãè¤éãªã®ã§ï¼
- .git/ ã®ç´æ¥ç·¨éï¼éªéãªã®ã§ï¼
ã¤ã¾ãã常ã«detached HEADã§éçºããsha-1ããã·ã¥ããã¼ãã«ã¡ã¢ããªããéçºãããã¨ã«ãªãã¾ãã
ããã«ããããGitã®åºç¤ã§ããããã·ã¥ï¼sha-1ï¼ãã©ããããã®ãï¼ãã¨ããã®ãåããã¾ãã*1
ãã®è¨äºã«ã¯ãcloneã¨ããpullã¿ãããªä¸ç´è ç¨ã®ã³ãã³ãã¯ç»å ´ãã¾ããã
Gitãªãã¸ããªã®æºå
ã¾ãã¯gitãªãã¸ããªãç¨æããå¿ è¦ãããã¾ãã
$ mkdir git_proj $ cd git_proj $ git init
masterãªãã¦ãã©ã³ãã¯ä¸è¦ãªã®ã§ãåé¤ãã¾ãããã ãããã«åé¤ãåºæ¥ãªãããã空ã®ã³ããããä½æãããã®å¾ã«masterãã©ã³ããåé¤ãã¾ãã
$ git commit --allow-empty -m "first commit" $ git log -n 1 (表示ãããsha-1ã®å¤ããã¼ãã«ã¡ã¢ãã) $ git checkout <ã¡ã¢ããsha-1> $ git branch -d master
ããã§æºåãåºæ¥ã¾ããã
å®éã«ä¸è¨ã®æé ã§ä½æ¥ããã®ãä¸è¨ã®ç»åã§ãã
ãã¡ã¤ã«ã®è¿½å /ã³ãããã®æé
åºæ¬çã«æ®éã®add/commitã¨åãã§ãã
ä¾
æ°ãããã¡ã¤ã«ãä½æãã¦ã追å ããå ´åã®ã³ãã³ããªã©ãè¨è¼ãã¦ã¿ã¾ããã
$ echo "Hello, Git World" > README.md $ git add README.md $ git commit -m "add README"
ã³ãããæ¯ã«ãã¼ãã«sha-1ã®å¤ãã¡ã¢ãã¦ãããæ¹ãè¯ãã§ããï¼ãã©ã³ãã使ããªãã®ã§ï¼
$ git log commit 421bcacadf8581e8cc459ea1254ee3990af967af Author: sinsoku <[email protected]> Date: Wed Jul 18 00:07:49 2012 +0900 add README commit 62f92f671d0e83d8a75fabd1dd46f64aa7b36dc6 Author: sinsoku <[email protected]> Date: Tue Jul 17 23:59:08 2012 +0900 first commit sinsoku@sinsoku-vm:~/Projects/sample/git_proj(git:(421bcac...)) $
ãã¡ã¤ã«ãå¤æ´ããã³ããããä½ã£ã¦ã¿ãã
markdownå½¢å¼ã«README.mdãå¤æ´ãã¦ã¿ã¾ããã
$ echo "# Hello, Git World" > README.md $ git add README.md $ git commit -m "markdownå½¢å¼ã«ç´ãã"
ãã°ã確èªãã¦ã¿ãã
$ git log -n 1 commit 1a8905309eac98743b3b2facd30db992ff0d5b9e Author: sinsoku <[email protected]> Date: Wed Jul 18 00:15:44 2012 +0900 markdownå½¢å¼ã«ç´ãã
ç§ã®ç°å¢ã§ã¯ããã®ãããªåºåã«ãªãã¾ããã
sha-1ã®å¤ã¯ç°å¢ã«ããç°ãªãã¾ããã大ä½ã®è¡¨ç¤ºã¯åãã«ãªãã¨æãã¾ãã
ãã©ã³ãé¢é£
branchã³ãã³ãã使ããªãã¦ããsha-1ãcheckoutãã¦ã³ããããããäºã§èªç¶ã«ãã°ãåå²ãã¾ãã
ä¾
ã¾ããadd READMEãã®sha-1ã®å¤ãcheckoutãã¦ã¿ã¾ãã
ï¼ãã®å¤ã¯å人ã§ç°ãªãã®ã§ãèªåã®ç°å¢ã®å¤ã使ãï¼
$ git checkout 421bcacadf8581e8cc459ea1254ee3990af967af Warning: you are leaving 3 commits behind, not connected to any of your branches: 1a89053 markdownå½¢å¼ã«ç´ãã 421bcac add README 62f92f6 first commit If you want to keep them by creating a new branch, this may be a good time to do so with: git branch new_branch_name 1a8905309eac98743b3b2facd30db992ff0d5b9e HEAD is now at 421bcac... add README sinsoku@sinsoku-vm:~/Projects/sample/git_proj(git:(421bcac...)) $
è¦åãåºã¦ãã¾ãããæ°ã«ããã«ä½æ¥ãã¾ãã
README.md ã¯ä½ããã¦ããã®ã§ãLicenseã®ãã¡ã¤ã«ã§ãä½æãã¦ã¿ã¾ãããã
$ touch LGPL-2.1 $ git add LGPL-2.1 $ git commit -m "add License"
ãã°ã確èªãã¾ãããã
$ git log commit 1aeb413b6d839d85074cc0e3f5fee9f1dfe16252 Author: sinsoku <[email protected]> Date: Wed Jul 18 00:29:18 2012 +0900 add License commit 421bcacadf8581e8cc459ea1254ee3990af967af Author: sinsoku <[email protected]> Date: Wed Jul 18 00:07:49 2012 +0900 add README commit 62f92f671d0e83d8a75fabd1dd46f64aa7b36dc6 Author: sinsoku <[email protected]> Date: Tue Jul 17 23:59:08 2012 +0900 first commit sinsoku@sinsoku-vm:~/Projects/sample/git_proj(git:(1aeb413...)) $
ãadd Licenseãã®ã³ãããã¯ãadd READMEãã®æ¬¡ã«ä½æããã¾ããã
ç¾å¨ã®ç¶æ
ã®è©³ç´°ãlogã®ãªãã·ã§ã³ã使ã£ã¦è¡¨ç¤ºãã¦ã¿ã¾ãã
$ git log --oneline --graph --decorate 1a8905309eac98743b3b2facd30db992ff0d5b9e 1aeb413b6d839d85074cc0e3f5fee9f1dfe16252 * 1aeb413 (HEAD) add License | * 1a89053 markdownå½¢å¼ã«ç´ãã |/ * 421bcac add README * 62f92f6 first commit sinsoku@sinsoku-vm:~/Projects/sample/git_proj(git:(1aeb413...)) $
ä¸è¨ã®ããã«ãã©ã³ããåºæ¥ã¦ãã¾ãã
ã§ã¯ãããããã¼ã¸ãã¾ãã
$ git merge 1a8905309eac98743b3b2facd30db992ff0d5b9e Merge made by the 'recursive' strategy. README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) sinsoku@sinsoku-vm:~/Projects/sample/git_proj(git:(9e97a14...)) $
ã°ã©ã表示ã§ãã°ã確èªãã¦ã¿ã¾ãã
$ git log --oneline --graph --decorate * 9e97a14 (HEAD) Merge commit '1a8905309eac98743b3b2facd30db992ff0d5b9e' into HEAD |\ | * 1a89053 markdownå½¢å¼ã«ç´ãã * | 1aeb413 add License |/ * 421bcac add README * 62f92f6 first commit sinsoku@sinsoku-vm:~/Projects/sample/git_proj(git:(9e97a14...)) $
ã¡ããã¨ãã¼ã¸ããã¦ãã¾ãã
ãªã¢ã¼ãã«ãã©ã³ããpush
remoteã³ãã³ããbranchã³ãã³ãã使ããªãããã
ä¾
$ git push [email protected]:sinsoku/git_proj.git 9e97a14:refs/heads/develop
ããã§ããªã¢ã¼ããªãã¸ããªã«developãã©ã³ããä½æããã¾ãã
ãªã¢ã¼ãã«ã¿ã°ãpush
ããã¯ãã©ã³ãã¨ã»ã¨ãã©åãã§ãã
ä¾
$ git push [email protected]:sinsoku/git_proj.git 9e97a14:refs/tags/v1.0.0
ãªã¢ã¼ãã®å¤æ´ãåãè¾¼ã
clone, pullã使ãããbranchã使ããªããããfetchã使ãã¾ãã
åãè¾¼ãã å¤æ´åæã®æå®ã¯å¸¸ã«sha-1ã使ãã¾ãã
ä¾
ä¾ã¨ãã¦ãgitã®ãªãã¸ããªã®å¤æ´ãåãè¾¼ãã§ã¿ã¾ãã
$ mkdir git $ cd git $ git init $ git fetch git://github.com/git/git.git
githubä¸ã§ç¢ºèªããã¨ãã¿ã° v1.7.11.2 ã®ããã·ã¥ã¿ã°ã¯ 8d141a1d562abb31f27f599dbf6e10a6c06ed73e ã®ããã§ãã
$ git log 8d141a1d562abb31f27f599dbf6e10a6c06ed73e commit 8d141a1d562abb31f27f599dbf6e10a6c06ed73e Author: Junio C Hamano <[email protected]> Date: Wed Jul 11 12:55:38 2012 -0700 Git 1.7.11.2 Signed-off-by: Junio C Hamano <[email protected]> commit b700086d840ceaee339f9f031be72b34e237f84f Merge: 2e1e8ef b31272f Author: Junio C Hamano <[email protected]> Date: Wed Jul 11 12:58:28 2012 -0700 Merge branch 'jc/maint-blame-unique-abbrev' into maint "git blame" did not try to make sure that the abbreviated commit object names in its output are unique. * jc/maint-blame-unique-abbrev: blame: compute abbreviation width that ensures uniqueness
ä¸è¨ã®ããã«ããã°ã表示ããã¦ãã¾ãï¼ï¼å¤æ´ãåå¾ã§ãã¦ãã¾ãï¼ã
åèæ¸ç±
- ä½è : 濱éç´(Junio C Hamano)
- åºç社/ã¡ã¼ã«ã¼: ç§åã·ã¹ãã
- çºå£²æ¥: 2009/09/24
- ã¡ãã£ã¢: åè¡æ¬
- è³¼å ¥: 31人 ã¯ãªãã¯: 736å
- ãã®ååãå«ãããã° (155件) ãè¦ã
Gitãã±ãããªãã¡ã¬ã³ã¹
- ä½è : 岡æ¬éå²,æ¦ç°å¥å¤ªé,ç¸è¯å¹¸ç¯
- åºç社/ã¡ã¼ã«ã¼: æè¡è©è«ç¤¾
- çºå£²æ¥: 2012/07/10
- ã¡ãã£ã¢: åè¡æ¬ï¼ã½ããã«ãã¼ï¼
- è³¼å ¥: 7人 ã¯ãªãã¯: 103å
- ãã®ååãå«ãããã° (26件) ãè¦ã
å¾æ¥è«
ãã®è¨äºã®è©±ãé£ã®äººã«è©±ããããåªåã®æ¹åæ§ãééã£ã¦ãããã¨è¨ããã¾ãã(´ã»Ïã»)
*1:ãã¶ã