2014åé ã«æ¸ãããWindowsã«ãããGitå©ç¨ç°å¢ã¯æ´ã£ãï¼ Git for Windows 㨠SourceTree for Windowsãã®æå¾ã®æï¼
ãã©ã³ãã¯ãGitã®ãªãã§æãéè¦ã§ãããªããæãåããã«ããæ¦å¿µã§ãããã表é¢çãªè¨èã«é¨ããããå å ¥è¦³ãæãããSourceTreeã®è¦è¦ç表示ï¼æ¨¹å½¢å³ï¼ã®åãåããªããå¦ç¿ããã®ããç解ã¸ã®ä¸çªã®è¿éã§ãã
ããã¸ãã®è©³ãããã¨ã¯ã¾ãã®æ©ä¼ã«è¿°ã¹ãããç¥ãã¾ããã
1å¹´å以ä¸ãã£ã¦ãã¾ãã¾ãããããã¾ãã®æ©ä¼ãããã£ã¦æ¥ã¾ãããããããGitã®èª¬æããã¾ãããã©ã³ããä¸å¿ã«è©³ããã
ãåºç¤ç·¨ãã¨ããã©ã³ãç·¨ãã§2åã«åããããã¨æã£ããã©ãé·å¤§ãªè¨äºã¨ãã¦ä¸æå ¬éãããããGitã使ã人ã対象ã§ã¯ããã¾ãããGitãä½ããã£ã¦ããã®ããèªåãä½ããã£ã¦ããã®ãã¤ãã¤ãèªä¿¡ãæã¦ãªãæ¹åãã§ãã
ãã©ã³ãããã¼ã¸ã£ã¦ããªãã ãããåãããªããªãä¸å®ã ãªãGitæããªããã¨æã£ã¦ãã人ã大ä¸å¤«ãããæããªãããã©ã³ã大好ãã«ãªãã¨æããã
åºç¤ç·¨ï¼
ãã®è¨äºã®åºæã«ãããã®ã¯ã
åºç¤ç·¨ã§ã¯ãGitã®ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã¨åç §ã·ã¹ãã ã®å é¨æ§é ãç解ãã¾ãã
- Gitã£ã¦æãã®ï¼
- Gitã¯ä½ãé ããªã
- 横çè ã®ããã®Gitå®é¨å®¤
- ãããèã ãGitãªãã¸ã§ã¯ã
- Gitãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹
- ææã¯ãããããGitã¯ä¿¡é ¼ã§ãã
- ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ãæ¢ãæºå
- ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã¯çµ¶å¯¾è¿½è¨å¼
- ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã¯ã°ã©ããã¼ã¿ãã¼ã¹
- ãªãã¸ã§ã¯ãã°ã©ãã®ä¸ãæ£çãã¦ã¿ã
- Gitãªãã¸ã§ã¯ãã®ç¨®é¡ã¨Gitãªãã¸ããªå ãã¡ã¤ã«ã·ã¹ãã
ãã©ã³ãç·¨ï¼
ãã©ã³ãç·¨ã§ã¯ãGitã®ãã©ã³ãã®æ§ã ãªå´é¢ãå®å ¨ã«ç解ãã¾ããããç¨åº¦ãåç¥ã®æ¹ã¯ãããããèªã¿å§ãã¦ããã¾ãã¾ãããå¿ è¦ãªã¨ãã«åºç¤ç·¨ãåç §ããã°ããã§ãããã
- ãã©ã³ãã¨HEADãã©ãã«ã¨ãã¦ã®ç解
- ã©ãã«ã®è¿½å ã¨åé¤ã¯ãã©ãã§ãããç¨ã«è»½ãä½æ¥
- å¤æ ãªãã¸ããªç»å ´
- AOSéåã¯ç解ãã¦ãã
- AOSéåãGitã«è¡¨ç¤ºããã
- AOSéåã®å ±éé¨åéå
- Gitã使ã£ã¦ããéåæ¼ç®ï¼å·®éåã¨å¯¾ç§°å·®éå
- ãã®éåæ¼ç®ãçã¯Gitã«èã
- ãã£ã¨ãæãã®æ¦å¿µã«ãã©ãçããã
- æé·ç¹ã¨ãã¦ã®ãã©ã³ã
- æåã°ã©ãã®ã¯ã¤ãº
- è¨ãæ®ããäºãªã©
[追è¨]
[/追è¨]
Gitã£ã¦æãã®ï¼
Gitãã¯ããã¨ãããã¼ã¸ã§ã³ç®¡çã·ã¹ãã ã¯ãå®å¿ã¨ãããèæ¯ã¨ããåæ°ãæã«å ¥ããããã®éå ·ã§ãããªã®ã«ãããããæããã£ã¦ã©ããããã¨ã§ãããï¼
- ããã©ã³ããåé¤ãããã³ããããæ¨ã¦ããããå¤æ´ãåãæ¶ããããã®ã³ãã³ããå¨ãã£ã¦ãã¨ã¯ãä¿åãããã¼ã¿ããã£ã±ãç¡ããªã£ã¦ãã¾ãã®ã§ã¯ï¼
- ãªãããããããããããããµãããè¡ããªããªã£ã¦ããªãã¸ããªãã¨æ¨ã¦ããããªãã®ã§ã¯ï¼
- ã³ã³ããªã¯ããã©ãå¦çãã¦ãããåãããªãããããã©ã³ããåæ£ãªãã¸ããªã¯ä½¿ããããªããã
- Subversionã®ãã¼ã¸ã§é ·ãæãããããããã³ãªã´ãªã ã
çéããæè¡è ã¯è¦ç¬ï¼ã¾ãã¯å²ç¬ï¼ãæµ®ãã¹ãããç¥ãã¾ããããåæ£ãã¼ã¸ã§ã³ç®¡çã·ã¹ãã ãç解ãããã¨ã¯å®¹æãããªãã§ããååãªãªãªã¨ã³ãã¼ã·ã§ã³ãªãã§åæ£ãã¼ã¸ã§ã³ç®¡çã·ã¹ãã ãä¸ããããã¨ã人ã¯ã¨ã¦ããã³ãã³ã«ã³ãªè¡åããã¾ãï¼ããªãã¸ã§ã³ç®¡çã·ã¹ãã ã使ããæè¡è ã¯ã¤ã±ããããåç §ãï¼
å¾ä½ã®ç¥ããªãã¢ãã¯æããã§ããããã ãããGitã®æ£ä½ãè¦æ¥µããªãã¨ãä¸å®æã»æææã¯ãªããªãæããªãã§ããããæãããã¨ã¯ç¥ããã¨ããå§ããããã§ãã
Gitã¯ä½ãé ããªã
Gitã®ãµãã³ãã³ãã¨ãªãã·ã§ã³ã¯è¨å¤§ã«ãããç解ããããè¦ãã«ãããã»ãã¨ã«ã¦ã³ã¶ãªãã¾ããããããGitã³ã¢ã®å é¨æ§é ã¯åç¶ã¨ããã»ã©ã«ã·ã³ãã«ã§ããå«æ°ãããã°ãã£ã°ãã£ã»ã´ã¿ã´ã¿ãæ»ãåãã奥ã«ãæå¿«ã§ç¾ããæ§é ãç«ã¡ç¾ãããæ§ã¯æåãã®ã§ãã
ããã®ç¾ãããçããªã«ä¼ããããã¨ãããã®ã·ã³ãã«ãããã¼ã¹ã«ç解ãã¹ããã¨ããæ°æã¡ã¯ããåããã¾ããä¾ãã°ãã翻訳ãGitãããã ã¢ããããç解ãããã®æåã®æ®µè½ã«ï¼å¼·èª¿ã¯æªå±±ï¼ï¼
ããã ã¢ããè¦ç¹ã§è¦ã Git ããããªã«ãç¾ããã·ã³ãã«ã§ãããªããç§ã調ã¹ããã¨ãä»ã®äººãèå³ãæã£ã¦èªãã§ãããã®ã§ã¯ãªããããããã¦ç§ãçµé¨ããè¦å´ãé¿ããããã®ã§ã¯ã¨èããã
ã¾ããid:propellaããã¯2011å¹´ã®æç¹ã§æ¬¡ã®ããã«ææãã¦ãã¾ããããã¡ã¤ã«ã·ã¹ãã ã¨ãã¦ã® Gitãããï¼å¼·èª¿ã¯æªå±±ï¼ï¼
Git ã®ã³ãã³ãä½ç³»ã¯å ¨ãæ´å²ã«å¦ã°ãå¾ä¸ã«ç¦æ ¹ãæ®ãé ·ããã¶ã¤ã³ã ããã©ããããããå é¨æ§é ã¯å¤§å¤ç´ æ´ãããã
Gitã®è³è³ãã¹ãç¾å¾³ã®ã²ã¨ã¤ã¯ããã®å é¨æ§é ãä¸åé ãã¦ãªããã¨ã§ãããã«è£¸ã®ç¶æ ããããã¤ãã¸ã¯ã®èã£ã±*1ãããè²æ®»*2ããããã¯èº«ã«ã¾ã¨ã£ã¦ããããªãã¨ããç¨åº¦ã§ãã
.git/ãã£ã¬ã¯ããªã®ä¸ã調ã¹ãã°ãGitãªãã¸ããªã®æ§é ãè¦ãè¦ã§ãã¾ããã¤ãã¸ã¯ã®èã£ã±ã§è¦ã£ã¦ããã¨æããã®ã¯ããã¤ããªãã¡ã¤ã«ãããããã§ããããããããå°æ°ã®Gitã³ãã³ãã ãã§ãã¤ããªã®è§£èªãã§ãã¾ãã
横çè ã®ããã®Gitå®é¨å®¤
Gitãç解ããã«ã¯ãå®é¨ã®ããã®ãªãã¸ããªãç¨æãã¦ãããåãã®ãè¿éã§ããã ãã©ããå®é¨ç°å¢ãä½ãã®ãå²ã¨ããã©ããããã§ãããã説æãç·´ç¿ã®ããã«ã¯å¤æ ãªãªãã¸ããªãããã®ã§ãããåå¿è ãã¤ãããªå¤æ ã«ã¯ãªãã¾ããã
ããã§ã横çè ï¼ã¤ã¾ãåèªèº«ï¼ã®ããã«å®é¨ç¨ãªãã¸ããªï¼å¤æ å«ãï¼ãä½ãåºãã¹ã¯ãªãããæ¸ãã¾ãããhttp://www.chimaira.org/misc/git-quest-kit.shar ã«ã·ã§ã«ã¢ã¼ã«ã¤ããç½®ãã¦ããã®ã§æ¬¡ã®ããã«ãã¾ããï¼ã½ã¼ã¹ã¯ https://github.com/m-hiyama/git-quest-kit )
$ curl http://www.chimaira.org/misc/git-quest-kit.shar > git-quest-kit.shar $ sh ./git-quest-kit.shar
Windowsã使ã£ã¦ãã人ãPOSIXã·ã§ã«ç°å¢ãæºåãã¦ãã ãããGit for Windowsã«bashã³ã³ã½ã¼ã«ãä»å±ãã¦ããã®ã§å¤§ä¸å¤«ã§ãããã
ä¸è¨ã®2è¡ã®ã³ãã³ããå®è¡ããã¨ã次ã®ã·ã§ã«ã¹ã¯ãªããéãçæããã¾ãã
- git-inspect-functions.sh -- Gitã®å é¨ã調ã¹ãããã®é¢æ°ï¼g_objectsã ã使ãï¼
- setup-git-sample-1.sh -- 1çªç®ã®ãµã³ãã«ãªãã¸ããªãä½ã
- setup-git-sample-2.sh -- 2çªç®ã®ãµã³ãã«ãªãã¸ããªãä½ãï¼ä»åã¯ä½¿ããªãï¼
- setup-git-sample-3.sh -- 3çªç®ã®ãµã³ãã«ãªãã¸ããªãä½ã
- clean-samples.sh -- ãµã³ãã«ãªãã¸ããªãæ¶å»ãã
ãã®ãªãã® setup-git-sample-1.sh ãå®è¡ï¼sh ./setup-git-sample-1.sh
ï¼ããã¨ã1çªç®ã®å®é¨ç¨ã®ãªãã¸ã㪠1-git-sample/ ãä½ããã¾ãã
ãªãã¸ããªãè¦è¦çã«ç¢ºèªããããã«SourceTreeããã£ãã»ããããã§ããããgitkã git log --graph ã§ãããã§ããã©ã
ãããèã ãGitãªãã¸ã§ã¯ã
Gitã³ã¢ã®ãããã«ä¸æ ¸ï¼ã³ã¢ã®ã³ã¢ï¼ã¨ãªãæ¦å¿µã¯ãªãã§ããããï¼ ããã¯ééããªãGitãªãã¸ã§ã¯ãã§ãããªãã¸ã§ã¯ãæåã¨ã¯é¢ä¿ãªãã§ããGitã«ããããªãã¸ã§ã¯ãã¨ã¯åãªããã¤ãåãã¼ã¿ã®ãã¨ã§ããã§ããããªãã¸ã§ã¯ãã«ã¯IDï¼ä¸æèå¥åï¼ãä»ãã¦ãã¾ãã
ãIDãä»ãããã¤ãåããGitãªãã¸ã§ã¯ãã§ããGitãªãã¸ã§ã¯ãã«ç¹å¾´çãªãã¨ã¯ããªãã¸ã§ã¯ãIDï¼ãªãã¸ã§ã¯ãåã¨ãè¨ãã¾ãï¼ãããªãã¸ã§ã¯ãã®ä¸èº«ãå®å ¨ã«è¡¨ãã¦ãããã¨ã§ããããã¯æ¬¡ã®ãã¨ãæå³ãã¾ãã
- ä¸èº«ãåã2ã¤ã®ãªãã¸ã§ã¯ãã¯ãåããªãã¸ã§ã¯ãIDãæã¤ã
- ãªãã¸ã§ã¯ãIDãåã2ã¤ã®ãªãã¸ã§ã¯ãã¯ãä¸èº«ãåãã
è¨ãæ¹ãå¤ããã¨ï¼
- ãªãã¸ã§ã¯ãIDãåããªãã¸ã§ã¯ãã¯ãåä¸ã®ãªãã¸ã§ã¯ãã¨ã¿ãªãï¼
ååï¼ãªãã¸ã§ã¯ãIDï¼ã«ãã£ã¦ãã¼ã¿å 容ãå®å ¨ã«èå¥ããã®ã§ãååã«é·ãååãå¿ è¦ã§ãã40æ¡ã®16é²æ°æååã使ããã¦ãã¾ãã
Gitã®ãªãã¸ã§ã¯ãIDã¯40æ¡ 6ed796a189da0d6f756dd31e82755b36690e33a2 ---------|---------|---------|---------|
Gitãªãã¸ã§ã¯ãã«ããã¦ã¯ããåãä½ã表ãããæç«ãã¦ãã¾ãããã®åç´ã«ãã¦å¼·åãªã¢ã¤ãã£ã¢ããåæ£ãã¼ã¸ã§ã³ç®¡çã·ã¹ãã Gitãæ¯ãã¦ããã®ã§ãã
Gitãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹
Gitãªãã¸ã§ã¯ãã¯ã©ãã«ããã®ã§ããããï¼ ãGitã¯ä½ãé ããªãããã¨ãæãåºãã¦ãã ããã.git/ãã£ã¬ã¯ããªã®é ä¸ã«ããã®ãªãã¸ããªã®ãã¹ã¦ã®ãªãã¸ã§ã¯ããæ ¼ç´ããã¦ãã¾ãã
$ alias ls # æåã«ãåã® ls ã¯ãããªã§ã alias ls='ls -aF --color=auto --show-control-chars' $ sh ./setup-git-sample-1.sh # å®è¡æ¸ã¿ãªãä¸è¦ã§ã ãªã«ãããã«ãã $ cd 1-git-sample/ # 1çªã®ãµã³ãã«ãªãã¸ããªãè¦ã«è¡ã $ ls .git ./ COMMIT_EDITMSG ORIG_HEAD description index logs/ refs/ ../ HEAD config hooks/ info/ objects/ $ ls .git/objects/ ./ 07/ 3d/ 8c/ 9c/ a7/ b9/ f5/ pack/ ../ 35/ 85/ 96/ a4/ ab/ be/ info/ $
ãµã³ãã«ãªãã¸ã㪠1-git-sample/ ã®ä¸ã®ã.git/objects/ ã«ä¸ã«ã¯2æåã®ååã®ãã£ã¬ã¯ããªãå¹¾ã¤ãããã¾ããä¸è¨ã®ä¾ãããªãã®ç°å¢ã¨åãã¨ã¯éãã¾ããããbe/ ã¯ããã¯ãã§ãã
$ ls .git/objects/be ./ ../ 3cf97185b993e42df63f601b8de2aefd046be2 $ cat .git/objects/be/3cf97185b993e42df63f601b8de2aefd046be2 ãã¤ããªãã¡ã¤ã«ãªã®ã§ã°ã¸ã£ã°ã¸ã£ $
ãªãã¸ããªã®ãã¹ã¦ã®ãªãã¸ã§ã¯ãã¯ã.git/objects/ ã®ä¸ã«é常ãã¡ã¤ã«ã¨ãã¦æ ¼ç´ããã¦ãã¾ãã40æ¡ã®ãªãã¸ã§ã¯ãIDã®ãã¡2æ¡ã¯ãµããã£ã¬ã¯ããªåãæ®ã38æ¡ããã¡ã¤ã«åã§ãããªãã¸ã§ã¯ãã®ä¸èº«ã¯å¯¾å¿ãããã¡ã¤ã«ã®å 容ãå§ç¸®ãããã¤ããªãã¼ã¿*4ã§ãããã¾catãããªãã¸ã§ã¯ãã¯ãa.txtã¨ãããã¡ã¤ã«å 容ã®å§ç¸®ãã¤ããªã§ããã
ãªãã¸ããªã®ãã¹ã¦ã®ãªãã¸ã§ã¯ããæ ¼ç´ããã¦ãããã£ã¬ã¯ã㪠.git/objects/ ããGitã®ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã¨å¼ã³ã¾ããããªããä¿åããããããã¢ãã¨ãããªãã¯æ°ä»ããªãããç¥ããªãé¢é£ããã¢ããããªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã«å ¥ã£ã¦ãã¾ãã
ææã¯ãããããGitã¯ä¿¡é ¼ã§ãã
Gitã®èª¬æã®ãªãã§ãããããGitãªãã¸ã§ã¯ããåé¤ï¼æ¶å»ï¼ãããããªè¡¨ç¾ãåºã¦ãã¾ããããã¯ï¼ä¸é¨ã®ä¾å¤ãé¤ãã¦ï¼è¨èã®ããã§ããé常ã®æä½ããããã¯ããããã¸ã§Gitãªãã¸ã§ã¯ããæ¶ãã®ã¯æ¥µãã¦å°é£ã§ãã
ãã¡ããããªãã¸ã§ã¯ããã»ãã¨ã«åé¤ããæ段ã¯ããã¾ããæ©å¯æ å ±ãééã£ã¦ãªãã¸ããªã«å ¥ãã¦ãã¾ã£ãæãªã©ããã®æ å ±ãæ¶ããªãã¨å°ãã¾ãããããã§ãããªã¢ã«ã«ãã¼ã¿ãåé¤ãããã¨ã¯ã¡ãã£ã¯ãã£é¢åã§ããGitãèªçºçã«ã´ãéãï¼garbage collectionï¼ãããã¨ãããã¾ããããããã¯ç¡è¦ãã¦ãããããã§ãã
ã¤ã¾ããäºå®ä¸ãªãã¸ã§ã¯ãã¯æ¶ããªãã®ã§ãã
ä¿åãããªãã¸ã§ã¯ãï¼ãã¼ã¿ï¼ãæ¶ããããã«è¦ãã¦ããå®éã«ã¯æ¢ãã«ãããªã£ã¦ããã ãã§ããå®å¿ãã¦ä¸ãããå ¥ã£ã¦ã¾ããã
ãªãã¸ã§ã¯ãã¯æ¶ããªãã°ãããå¤æ´ãã§ãã¾ããããããªãã¸ã§ã¯ãã®ä¸èº«ï¼ãã¤ãåãã¼ã¿ï¼ãå¤ããã°ãååï¼ãªãã¸ã§ã¯ãIDï¼ãå¤ããã¾ããååãéãã°å¥ãªãªãã¸ã§ã¯ãã§ããååãå¤ããã«ä¸èº«ãå¤ãããã¨ãåççã«ä¸å¯è½ãªã®ã§ãã
å³å¯ã«è¨ãã°ãéãä¸èº«ã§åãååã®ãªãã¸ã§ã¯ããåºç¾ããå¯è½æ§ã¯ããã¾ãããããããã¯ãè¶ ã ãã§ã¼ç¨ã§ããªãã¸ã§ã¯ãIDã®è¡çªãå¿é ããã®ã¯ã太é½ãè¨å¼µãã¦å°çã飲ã¿è¾¼ããã¨ãæ¯æ¥å¿é ãããããªãã®ã§ãã
ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ãæ¢ãæºå
ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã®ãã£ã¬ã¯ã㪠.git/objects/ ã¯ãåãªããªãã¸ã§ã¯ãã®éåã¨ããããã§ã¯ãªãããã£ã¨æ½è±¡çãªãã¼ã¿æ§é ã¨æããã¹ãã§ããã©ããªæ§é ãªã®ã§ããããï¼ ãããæ¢ã£ã¦ããã¾ãããã
æ¢ç´¢ã»èª¿æ»ãå©ããããã®ã·ã§ã«é¢æ°ã git-inspect-functions.shï¼http://www.chimaira.org/misc/git-quest-kit.shar ããå±éï¼ã«å ¥ã£ã¦ãã¾ãã次ã®ããã«ãã¦å©ç¨å¯è½ã«ãã¾ãã
$ . ./git-inspect-functions.sh
æ¥æ¬èªã¡ãã»ã¼ã¸ãutf-8ã¨ã³ã³ã¼ãã£ã³ã°ã§å
¥ã£ã¦ãã¾ããã³ã³ã½ã¼ã«ãutf-8ã表示ã§ããªãã¨ãã¯ç°å¢å¤æ°CONSOLE_ENCODINGãã»ãããã¦ãã ããï¼ä¾ï¼ export CONSOLE_ENCODING=sjis
ï¼
æ¢ç´¢ã»èª¿æ»ç¨ã®ã·ã§ã«é¢æ°ã¯ååã¯ãg_ãã§å§ã¾ã£ã¦ãã¦ãg_help
ã¨ããã¨å
¨ã¦ã®é¢æ°ã®ãã«ãã表示ããã¾ãããããã®é¢æ°ã¯gitã³ãã³ããã©ãããã¦ãã¦ä¾¿å©ã ã¨æãã¾ããã説æã®ãªãã§ã¯ãªãã¹ãçã®gitã³ãã³ãã使ç¨ãã¾ããããããã¨ãããã次ã®ãg_é¢æ°ãã¯ä½¿ãã¾ãã
- g_objects -- ãªãã¸ããªï¼ã®ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ï¼ã«å«ã¾ããå ¨ã¦ã®ãªãã¸ã§ã¯ããåæãã¾ãã
g_objectsé¢æ°ã¯ã(cd .git/objects/; find -type f) | sed -e 's@^\.@@' -e 's@/@@g'
ãè¡ãã¨æã£ã¦ãã ããã
ãªããg_objectsé¢æ°ã¯ãå°è¦æ¨¡ãªãµã³ãã«ã調ã¹ãããã®ãã®ã§ã大ããªãªãã¸ããªã§ã¯æ£ããåããªãããç¥ãã¾ãã*6ãgit-quest-kit.sharå ã®ã¹ã¯ãªããã¯ããã¾ã§å¦ç¿ç®çã¨å¿å¾ã¦ãã ãããã
ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã¯çµ¶å¯¾è¿½è¨å¼
ã§ã¯ãã¡ãã£ã¨å°æ調ã¹ãã
$ sh ./setup-git-sample-1.sh # å®è¡æ¸ã¿ãªãä¸è¦ã§ã ãªã«ãããã«ãã $ . ./git-inspect-functions.sh # å®è¡æ¸ã¿ãªãä¸è¦ã§ã $ cd 1-git-sample/ # 1çªã®ãµã³ãã«ãªãã¸ããªãè¦ã«è¡ã $ g_objects 0718ba5d0a618675379e644c0bfa663c6234de22 358462e3ad874af2e3fd06cf0e806058b3179393 3d80f31c7e1ff1405291ab7aeb88d4e943aee689 853e2b3e200f8c3d33badb87f225f7b46169fe2f 8cbb43e0bda4053373e0efeea4fb50e03e8f1f50 9632a673ddb364c9f46427b2e7f6fcd1548334f0 9c08c2d14ddce27ca14ae6f4b78861cfa8d5caf6 a47fb14178e7a18ddabbf52f497813206ee184fb a7cf72c7a33bee6b555087c27d8298bde1791d7c ab6dbf626e0622caead0d2782204b39fba7faef2 b945b3c51935ccd856124fb2548a87e0f55b3ee5 be3cf97185b993e42df63f601b8de2aefd046be2 f5888fcb7e0112d8d14b80d25e34d3a2fe99e84c $
ã¦ã®ã£ã¼ãããªããããããã
40æ¡ã®16é²æ°æååã®ç¾ åãè¦ãããã¦ããµãããªåãããªãã§ããããã§ããããã§ãªãã¸ã§ã¯ãã®åæ°ã調ã¹ããã¾ãã
$ g_objects | wc -l 13 $
13åã®ãªãã¸ã§ã¯ããããã¾ããããªãã¸ã§ã¯ãã¯æ¶ããªãããã¨ã確èªãã¾ãããã
$ echo x> x.txt $ git add x.txt $ g_objects | wc -l 14 $
git add ããã ãã§ã¯ãã¡ã¤ã«ã¯ç»é²ãããªãã¨ç¿ã£ãã§ãããããå®éã«ã¯ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã«ç»é²ããã¾ãããªãã¸ã§ã¯ãã1åå¢ãã¦14åã§ããgit addã¯ååã®éãããªãã¸ã§ã¯ãããã³ãã«è¿½å ãã¾ãã
git addãåãæ¶ãã¦ã¿ã¾ããããä»®ç»é²ããããªãã¸ã§ã¯ããæ¶ããã¨æãã¾ããï¼
$ git status # ã¹ãã¼ã¿ã¹ãç¢ºèª On branch master Changes to be committed: (use "git reset HEAD..." to unstage) new file: x.txt $ git reset HEAD x.txt # ä»®ç»é²ãåãæ¶ã $ git status # ã¹ãã¼ã¿ã¹ãç¢ºèª On branch master Untracked files: (use "git add ..." to include in what will be committed) x.txt nothing added to commit but untracked files present (use "git add" to track) $ g_objects | wc -l # ãªãã¸ã§ã¯ãã®åæ° 14 $
14åã®ã¾ã¾ã§ããä»®ç»é²ã§ãããä¸åº¦addãããããæ¶ããã¨ã¯åºæ¥ã¾ããããªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã«ã·ãã«ãªã¨å ¥ã£ã¦ããã®ã§ã*7ã
次ã«ããã²ã¨ã¤åã®ã³ããããåãæ¶ãã³ãã³ããã¨è¨ããã¦ãã git commit --amend ãã£ã¦ã¿ã¾ãã
$ g_objects | wc -l # ãªãã¸ã§ã¯ãã®åæ° 14 $ git log -s | grep commit commit f5888fcb7e0112d8d14b80d25e34d3a2fe99e84c # â æ³¨ç® commit a47fb14178e7a18ddabbf52f497813206ee184fb commit 9c08c2d14ddce27ca14ae6f4b78861cfa8d5caf6 commit 358462e3ad874af2e3fd06cf0e806058b3179393 $ git commit --amend -m amended # ã²ã¨ã¤åã®ã³ããããåãæ¶ã [master 2cd9a51] amended Date: Fri Sep 25 14:33:26 2015 +0900 $ git log -s | grep commit commit 2cd9a511ca077d9613cf30308d30a265b06f25e0 # â æ³¨ç® commit a47fb14178e7a18ddabbf52f497813206ee184fb commit 9c08c2d14ddce27ca14ae6f4b78861cfa8d5caf6 commit 358462e3ad874af2e3fd06cf0e806058b3179393 $ g_objects | wc -l # ãªãã¸ã§ã¯ãã®åæ° 15 $
確ãã«ææ°ã®ã³ããããå ¥ãæ¿ãã£ã¦ãã¾ãããããããªãã¸ã§ã¯ãæ°ã¯ã14åãã15åã«å¢ãã¦ãã¾ããã³ãããã¯æ¶ãã¦ãªãã¦ããªããã§ããè¦ããªããªã£ãã ãã§ã -- ããã¨ãªã£ããè¦ã¤ãã¦åãåºããã¨ãåºæ¥ã¾ã*8
ãåé¤ããããåãæ¶ãããä¿®æ£ãããã¨ãã£ã表ç¾ãããã¦ãã¦ããããã¯è¨èã®ããï¼å³å¯ã«ã¯åï¼ã§ããGitã®ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã¯çµ¶å¯¾è¿½è¨å¼ã®ã¹ãã¬ã¼ã¸ã§ãåé¤ãå¤æ´ãåºæ¥ã¾ããã
ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã¯ã°ã©ããã¼ã¿ãã¼ã¹
Gitã®ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã®æ§é ããã£ã¨è©³ããè¦ã¾ããããå ã»ã©ã®å®é¨ã®å¹æãåãæ¶ãããã«æ¬¡ã®ããã«ãã¾ãã
$ cd .. $ sh ./clean-samples.sh # ãµã³ãã«ãæ¶å» removing 1-git-sample $ sh ./setup-git-sample-1.sh # ããä¸åº¦ãµã³ãã«ãªãã¸ããªãä½ã ãªã«ãããã«ãã $
ã³ãããã®è¦ªåé¢ä¿ãã°ã©ãã£ã«ã«ã«è¦ãããã«SourceTreeã使ããã¨ã«ãã¾ãããµã³ãã«ãªãã¸ããªã®æ¨¹å½¢å³ã¯æ¬¡ã®ããã«ãªãã¾ãã
4åã®ã³ããããªãã¸ã§ã¯ããæããã¦ãã¾ãããããããã®ãµã³ãã«ãªãã¸ããªï¼ã®ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ï¼ã«ã¯13åã®ãªãã¸ã§ã¯ããããã®ã§ãããæ®ãã®9åã¯ã©ããªã£ã¦ããã®ï¼
ã¯ããåï¼æªå±±ï¼ãé å¼µã£ã¦13åå ¨é¨ã®ãªãã¸ã§ã¯ãã¨ç¸äºé¢ä¿ã¾ã§æãã¾ããããï¼ããã大å¤ã ã£ãããï¼
ãªãã¸ã§ã¯ãï¼ã°ã©ãã®ãã¼ãï¼ã®æ°ãåå®ãã¦ããã¡ããã¨13åããã§ãããããã§å ¨é¨ã
Gitã®ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ãã©ããªç¨®é¡ã®ãã¼ã¿ãã¼ã¹ãã¨è¨ãã¨ãé¢ä¿ãã¼ã¿ãã¼ã¹ã¨ã¯éããããã¥ã¡ã³ããã¼ã¿ãã¼ã¹ã¨ãè¨ãããããã°ã©ããã¼ã¿ãã¼ã¹ã«è¿ãã§ããããªãã¸ã§ã¯ãéã®é¢é£æ§ã示ãã°ã©ã辺ããã¼ã¿ãã¼ã¹å é¨ã§è¡ã交ã£ã¦ãã¾ããããã¦ããã¼ã¿ãã¼ã¹ã®å¤é¨ãããªãã¸ã§ã¯ããæã示ãããã®åç §ã®ã°ã©ã辺ãé£ã³è¾¼ãã§ãããããããæ§é ããã¦ãããã
ãªãã¸ã§ã¯ãã°ã©ãã®ä¸ãæ£çãã¦ã¿ã
Gitãªãã¸ã§ã¯ãéãä½ãæåã°ã©ãï¼directed graphï¼ããªãã¸ã§ã¯ãã°ã©ãã¨å¼ã¶ãã¨ã«ãã¾ãããªãã¸ã§ã¯ãã°ã©ãã貯ãã¦ãããã¼ã¿ãã¼ã¹ãGitãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã¨ãããã¨ã«ãªãã¾ãã
ããããå ã¯ããªãã¸ã§ã¯ãã°ã©ãã®çµµãçºããªããèªãã§ãã ããï¼åãçµµãè¦ãªããæ¸ãã¦ãã¾ãï¼ãhttp://www.chimaira.org/img3/git-sample-1-whole-graph.png ããã©ã¦ã¶ãç»åãã¥ã¼ã¢ã®å¥ã¦ã£ã³ãã¦ã«è¡¨ç¤ºããããå°å·ããã¨ããã§ããã
ãªãã¸ã§ã¯ãã°ã©ãã®ãã¼ãã§ãããªãã¸ã§ã¯ãã¯ã40æ¡ã®IDã§èå¥ã§ãã¾ãããããã40æ¡ã®IDãæ±ãã人ãªãã¦ããªãããã§ã人éå¯èªãªååã«ããåæããå¿ è¦ã§ãããã®åæãã®æ段ãæä¾ããã½ããã¦ã§ã¢é¨åããGitã®åç §ã·ã¹ãã ã¨å¼ã³ã¾ããããçµµã§ã¯ãã³ã¯ã¨èµ¤ã®ã¨ããã§ãã
åç §ã·ã¹ãã ãããã®ã§ããªãã¸ã§ã¯ãIDã使ããã«ãªãã¸ã§ã¯ãã°ã©ããæ±ããããã«ãªãããã¼ã¸ã§ã³ç®¡çã·ã¹ãã ã¨ãã¦ã®æ§ã ãªæ©è½ãå®è£ ã§ããã®ã§ãã
çµµã®ãã³ã¯ã®å²ãã®ãªãã«ãã人éå¯èªãªååããã©ãã«ã¨å¼ã¶ãã¨ã«ãã¾ãããããã®ã©ãã«ã®å®ä½ã¯ã©ãã«ããã®ã§ãããããGitã¯ä½ãé ããªããã®ã§ããããã¡ããã.git/ãã£ã¬ã¯ããªã®ä¸ã«ããã¾ãã
ã©ãã« | 対å¿ãããã¡ã¤ã« |
---|---|
HEAD | .git/HEAD |
master | .git/refs/heads/master |
topic | .git/refs/heads/topic |
tag_second | .git/refs/tags/tag_second |
ã©ãã«ã«å¯¾å¿ãããã¡ã¤ã«ãè¦ãè¦ãã¦ã¿ã¾ãã
$ cat .git/HEAD ref: refs/heads/master $ cat .git/refs/heads/master 8eedab38d83c5085058f3ce153fe6d466df61157 $ cat .git/refs/heads/topic e4ff254f976a7202a3b88ff3aef3e63aa225124d $ cat .git/refs/tags/tag_second b1edd575f4e21096623bec4d2cf06ff4684d4342 $
ããã¹ããã¡ã¤ã«ã®å 容ã¨ãã¦ãªãã¸ã§ã¯ãIDãè¨é²ãããã¨ã«ããã©ãã«ãå®ç¾ãã¦ããã®ã§ããç´ æ´ã»ç°¡åã§ãããHEADã¯ããã£ãã refs/heads/masterï¼ãã¡ã¤ã«ã®ç¸å¯¾ãã¹åï¼ãçµç±ãã¦ãããªãã¸ã§ã¯ãIDã«ãããªãã¸ã§ã¯ããåç §ãã¦ãã¾ãã
ãªãã¸ã§ã¯ãã®ä¸èº«ã¯ãã¤ããªã§ããããããã解èªãã¦äººéå¯èªåå¼ã§è¡¨ç¤ºãã¦ãããã³ãã³ãã git cat-file ã§ããgit cat-file ã®å¼æ°ã¯ã©ãã«ã§ããã®ã§ãããããã¯çã ããç¦ã ããé°å²æ°ãå³ããããã«ããªãã¸ã§ã¯ãIDãã³ãããã¦ä½¿ãã¾ãããã
$ git cat-file -t 8eedab38d83c5085058f3ce153fe6d466df61157 # ãã®ãªãã¸ã§ã¯ãã®å commit # ãã®ãªãã¸ã§ã¯ãã¯commitåãªãã¸ã§ã¯ã $ git cat-file -p 8eedab38d83c5085058f3ce153fe6d466df61157 # ãã®ãªãã¸ã§ã¯ãã®ä¸èº« tree 8cbb43e0bda4053373e0efeea4fb50e03e8f1f50 parent b1edd575f4e21096623bec4d2cf06ff4684d4342 parent e4ff254f976a7202a3b88ff3aef3e63aa225124d author m_hiyama1443162786 +0900 committer m_hiyama 1443162786 +0900 merged $
ã³ã³ã½ã¼ã«è¡¨ç¤ºã®çµæãåããããã表ã«ã¾ã¨ããã¨ï¼ãªãã¸ã§ã¯ãIDã¯å é é¨ã®ã¿*9ï¼ï¼
ãã®ãªãã¸ã§ã¯ãã®IDï¼æ¢ç¥ï¼ | 8eedab3... |
ãã®ãªãã¸ã§ã¯ãã®å | commit |
treeåç §å ã®ãªãã¸ã§ã¯ãID | 8cbb43e... |
parentåç §å ã®ãªãã¸ã§ã¯ãID | b1edd57... |
parentåç §å ã®ãªãã¸ã§ã¯ãID | e4ff254... |
ã³ãããã¡ãã»ã¼ã¸ | merged |
ãªãã¸ã§ã¯ãã®åã«ã¯commitåï¼çµµã§ã¯äºéæ æ¥åï¼ä»¥å¤ã«treeåï¼çµµã§ã¯ãã©ã«ãã¼å½¢ï¼ãblobåï¼çµµã§ã¯æ¥åï¼ãããã¾ããåã«ã¤ãã¦ã¯å¾ã§èª¬æãã¾ãããtreeåç §ï¼çµµã§ã¯éç·ç¢å°ï¼ã®å ã¯treeåãªãã¸ã§ã¯ããparentåç §ï¼çµµã§ã¯éç¢å°ï¼ã®å ã¯commitåãªãã¸ã§ã¯ãã ã¨æ±ºã¾ã£ã¦ãã¾ãããã£ã¦ãããã¾ã§ã®æ å ±ãããªãã¸ã§ã¯ãã°ã©ãã®ä¸é¨(â)ãæãã¾ãã
åãããã«ãã¦ããªãã¸ã§ã¯ãIDã§åç §ãããå ããã³ãã³ãã©ã£ã¦ããã°ããã¼ã¿ãã¼ã¹å ã®ãªãã¸ã§ã¯ãéã¨ãã®ç¸äºé¢é£ã®ã°ã©ããæããã¨ãåºæ¥ã¾ãã人éã«ã¨ã£ã¦ãã®ä½æ¥ã¯è¾ãã§ãããã³ã³ãã¥ã¼ã¿ã¼ã«ã¯ãã¨ãããããäºã§ãã
Gitãªãã¸ã§ã¯ãã®ç¨®é¡ã¨Gitãªãã¸ããªå ãã¡ã¤ã«ã·ã¹ãã
Gitãªãã¸ã§ã¯ãã¯æ¬¡ã®3種ã«å¤§åé¡ã§ãã¾ãã
- ã³ããããªãã¸ã§ã¯ã
- commitåãªãã¸ã§ã¯ã -- ã³ãããã表ã
- ãã¡ã¤ã«ã·ã¹ãã ãªãã¸ã§ã¯ã
- treeåãªãã¸ã§ã¯ã -- ãã¡ã¤ã«ã·ã¹ãã ã®ãã£ã¬ã¯ããªã«å¯¾å¿ãã
- blobåãªãã¸ã§ã¯ã -- ãã¡ã¤ã«ã·ã¹ãã ã®ãã¡ã¤ã«ã«å¯¾å¿ãã
- ãã®ä»
- ã¢ããã¼ã·ã§ã³ä»ãã¿ã°ã表ããªãã¸ã§ã¯ã
- ãµãã¢ã¸ã¥ã¼ã«ã表ããªãã¸ã§ã¯ã
ãã³ããããã¨ããè¨èã«ã¯åè©ã¨åè©ãããã¾ãããåè©ï¼è¡çºï¼ã¨ãã¦ã®ã³ãããã«ãããåè©ï¼ãªãã¸ã§ã¯ãï¼ã¨ãã¦ã®ã³ãããã1åä½ããã¾ãããã¼ã¸ã«ãã£ã¦ãã³ããããªãã¸ã§ã¯ããä½ããã¾ãããããã¯Gitãèªåçã«ã³ãããï¼è¡çºï¼ãã¦ãã ãã§ãã
ã³ãããï¼è¡çºï¼ã¯ãè¨é²ã»ä¿åãããä¸ç¾¤ã®ãã¡ã¤ã«ãGitãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã«æ ¼ç´ãããã¨ã§ãã1åã®ãã¡ã¤ã«ã¯1åã®blobåãªãã¸ã§ã¯ãã«ãªãã1åã®ãã£ã¬ã¯ããªã¯1åã®treeåãªãã¸ã§ã¯ãã«ãªãã¾ããããã¦å ¨ä½ã¨ãã¦ã¯ããªã¼æ§é ãå½¢æãã¾ãããã®ããªã¼æ§é ã1åã®ã³ããããªãã¸ã§ã¯ãã«ç´ä»ãã¦ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã«æ ¼ç´ããã¾ãããã¡ã¤ã«ã·ã¹ãã ããªã¼ãããªãã¸ã§ã¯ãã°ã©ãã®ä¸é¨ã¨ãã¦åãè¾¼ã¾ãã¦æ°¸ä¹ åçµãããããã
ããã¾ã§ã®è©±ã§ãGitã¯åæç¹ã§ã®ãã¡ã¤ã«éã丸ã æ±ãã¦ãããã¨ãåããã§ããããçµµ http://www.chimaira.org/img3/git-sample-1-whole-graph.png ã§a.txtã2ã¤ããã®ã¯ãå¤æ´åã¨å¤æ´å¾ã®a.txtã2ã¤ã¨ãæã£ã¦ããããã§ããããããåãå 容ã®ãã¡ã¤ã«ãéè¤ãã¦æã¤ãã¨ã¯ããã¾ããããä¸èº«ãåã2ã¤ã®ãªãã¸ã§ã¯ãã¯ãåããªãã¸ã§ã¯ãIDãæã¤ãã®ã§ãåããã¼ã¿ãéè¤ãã¦ã¯æã¦ãªãã®ã§ãã
Gitãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹å ã®ãã¡ã¤ã«ã·ã¹ãã ã¯ãUnixãã¡ã¤ã«ã·ã¹ãã ã¨ã»ã¨ãã©åãã§ããä¸èº«ï¼ãã¼ã¿å 容ï¼ãåããã¡ã¤ã«ï¼blobåãªãã¸ã§ã¯ãï¼ããã£ã¬ã¯ããªï¼treeåãªãã¸ã§ã¯ãï¼ã¯ããã¼ããªã³ã¯ï¼åä¸ãªãã¸ã§ã¯ãã¸ã®åç §ï¼ã«ãã£ã¦å ±æããã¾ããå ±æã¯ãã£ã¹ã¯ã®ç¯ç´ã«ãå½¹ç«ã¡ã¾ãã
ãã£ã¬ã¯ããªã«ç¸å½ããtreeåãªãã¸ã§ã¯ããè¦ãã¦ã¿ã¾ããããã
$ git cat-file -t 8cbb43e0bda4053373e0efeea4fb50e03e8f1f50 # ãã®ãªãã¸ã§ã¯ãã®å tree # treeåãªãã¸ã§ã¯ã $ git cat-file -p 8cbb43e0bda4053373e0efeea4fb50e03e8f1f50 # ãã®ãªãã¸ã§ã¯ãã®ä¸èº« 100644 blob be3cf97185b993e42df63f601b8de2aefd046be2 a.txt 100644 blob 0718ba5d0a618675379e644c0bfa663c6234de22 b.txt 040000 tree ab6dbf626e0622caead0d2782204b39fba7faef2 subdir $
treeåãªãã¸ã§ã¯ãã®ä¸èº«ã¯ããblobåãªãã¸ã§ã¯ãï¼ãã¡ã¤ã«ç¸å½ï¼ãä»ã®treeåãªãã¸ã§ã¯ãï¼ãµããã£ã¬ã¯ããªç¸å½ï¼ã®ãªãã¸ã§ã¯ãIDã¨ããã¡ã¤ã«åãã®ä¸¦ã³ã§ãã左端ã®100644ãªã©ã®æ°å¤ã¯ããªãã¸ã§ã¯ãã®åã¨ãã¡ã¤ã«ãã¼ããã·ã§ã³ï¼644ãªã©ï¼ãçµã¿åããããã©ã°ã§ã*10ã以ä¸ã®çµµã§ã¯ããªãã¸ã§ã¯ãIDã«ããåç
§ãitemã¨ã©ãã«ãããã°ã©ã辺ï¼ç¢å°ï¼ã§è¡¨ç¾ãã¦ã¾ãã
çµµã§ã¯ããã¡ã¤ã«åãblobåãªãã¸ã§ã¯ãå´ã«ã©ãã«ãã¦ã¾ããããã¡ã¤ã«åãå«ããã¡ã¿ãã¼ã¿ã¯ãã¹ã¦treeåãªãã¸ã§ã¯ãå´ã§ä¿æãã¦ãã¾ããblobåãªãã¸ã§ã¯ãã«ã¯ç¡å¢ãªãã¼ã¿ã ããè©°ãè¾¼ã¾ãã¦ããã®ã§ãã
ãã¦ãããããããããããã©ã³ãç·¨ãã§ãã
ãåºç¤ç·¨ãã§èªã¿ç²ããæ¹ã¯ãã²ã¨ä¼ã¿ãã¦ç¶ãã¯ææ¥ã«ãã¾ãããã
- ãã©ã³ãã¨HEADãã©ãã«ã¨ãã¦ã®ç解
- ã©ãã«ã®è¿½å ã¨åé¤ã¯ãã©ãã§ãããç¨ã«è»½ãä½æ¥
- å¤æ ãªãã¸ããªç»å ´
- AOSéåã¯ç解ãã¦ãã
- AOSéåãGitã«è¡¨ç¤ºããã
- AOSéåã®å ±éé¨åéå
- Gitã使ã£ã¦ããéåæ¼ç®ï¼å·®éåã¨å¯¾ç§°å·®éå
- ãã®éåæ¼ç®ãçã¯Gitã«èã
- ãã£ã¨ãæãã®æ¦å¿µã«ãã©ãçããã
- æé·ç¹ã¨ãã¦ã®ãã©ã³ã
- æåã°ã©ãã®ã¯ã¤ãº
- è¨ãæ®ããäºãªã©
ãã©ã³ãã¨HEADãã©ãã«ã¨ãã¦ã®ç解
次ã®ãããªèª¬æãè¦ããã¨ãããã¾ãã
- ã½ããã¦ã§ã¢éçºã®ã¡ã¤ã³ã©ã¤ã³é¨åããã©ã³ã¯ï¼å¹¹ï¼ã¨å¼ã³ãããããæ´¾çããæããã©ã³ãã¨å¼ã¶ã
Gitã®ãã©ã³ãã¯ãã®ãããªãã®ã§ã¯ããã¾ããããã®ããã«ç解ãããã¨ãã¦ãç¡çã§ã誤解ã¨æ··ä¹±ã«é¥ãã ãã§ãã
ä»æ´è¨ã£ã¦ããããããªããã©ãããã©ã³ããã¨ããä¼çµ±çç¨èªãæµç¨ããªãã§ããã«ã¼ã½ã«ãã¨ãããã¤ã³ã¿ãã¨ãå¼ã¹ã°ããã£ãã®ã«ãã¨ããæ°ããã¾ãã
åã®ç¥ãç¯å²ã§ãããã©ã³ããã¨ããè¨èã¯æ¬¡ã®5ã¤ãããã®æå³ã§ä½¿ããã¦ãã¾ãã
- ã³ããããªãã¸ã§ã¯ããæãï¼åç §ããï¼ã©ãã«
- ã©ãã«ããæãããï¼åç §ãããï¼ã³ããããªãã¸ã§ã¯ã
- ç¹å®ã®ã³ããããªãã¸ã§ã¯ãã«å¯¾ãããèªåãå«ãç¥å ã³ãããéå
- 2ã¤ã®ã³ãããéåã®å·®éå
- ã°ã©ãã®åå²ãã¼ã
ãã®ãªãã§ãé£ããæ¦å¿µã§ããã2ã¤ã®ã³ãããéåã®å·®éåãã®ç¹æ®ãªå ´åããå¹¹ã«å¯¾ãããæãã«å¯¾å¿ãã¾ããé£ããç¹æ®ãªã¨ããããåºçºãã¦åãããããªãã§ããããã
ç°¡åãªè©±ããå§ãã¾ããããGitã®åç §ã·ã¹ãã ã«ã¤ãã¦ã¯æ¢ã«è¿°ã¹ã¾ãããå ã®çµµã®ããã«ãå¹¾ã¤ãã®ã©ãã«ããããã©ãã«ãã³ããããªãã¸ã§ã¯ããåæãï¼åç §ï¼ãã¦ããã®ã§ãããã©ãã«ã«ã¯åºå®ã©ãã«ã¨å¤åã©ãã«ãããã¾ããåºå®ã©ãã«ã®åç §å ãªãã¸ã§ã¯ãã¯å¤ãããã¾ãããä¸æ¹ãå¤åã©ãã«ã®åç §å ãªãã¸ã§ã¯ãã¯ã©ãã©ãå¤ããã¾ãã
åºå®ã©ãã«ãã¿ã°ã¨å¼ã³ãå¤åã©ãã«ããã©ã³ãã¨å¼ã¶ãããæã£ã¦ãã ããããã ããHEADã©ãã«ã¯å¤åãã¾ããç¹æ®ãªã®ã§ãã©ã³ãã¨ã¯å¼ã³ã¾ããã
HEADã¯é常ãä»ã®ã©ãã«ãæãã¾ãããHEAD â ä»ã®ã©ãã« â ãªãã¸ã§ã¯ããã¨åç §ã2åãã©ã£ã¦ãªãã¸ã§ã¯ãã«å°éãã¾ããHEADãæãã³ããããªãã¸ã§ã¯ããã«ã¬ã³ãã®ã³ãããã§ããã«ã¬ã³ãã®ã³ãããã«ç´ä»ããªãã¸ããªå ã®ãã¡ã¤ã«ã·ã¹ãã ããªã¼ããã¯ã¼ã¯ããªã¼ï¼ä½æ¥ãã£ã¬ã¯ããªã®ããªã¼ï¼ã¨æ¯è¼ããã¾ãã
ããã©ã³ããããæããæå³ããªãã®ã¨åæ§ã«ããããããï¼HEADï¼ã«ãå é ãã®æå³ã¯ããã¾ãããHEADã¯å¿ ãããä»ã®ã©ãã«ãçµç±ããå¿ è¦ããªããç´æ¥ã«ã³ããããªãã¸ã§ã¯ããåç §ã§ãã¾ããHEADã¯ãã©ã®ã³ããããªãã¸ã§ã¯ããåç §ãã¦ããã¾ãã¾ããã
ãµã³ãã«ãªãã¸ããªã§å®é¨ãã¦ã¿ã¾ãããã
$ cat .git/HEAD # HEADã®åç §å ref: refs/heads/master $ git checkout HEAD^ # ç¾å¨ã®HEADã®è¦ªã³ããããã«ã¬ã³ãã«ãã Note: checking out 'HEAD^'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -bHEAD is now at b1edd57... second $ cat .git/HEAD # å¤æ´å¾ã®HEADããªãã¸ã§ã¯ãIDã«ããç´æ¥åç §ã«ãªã£ã¦ããã¯ã b1edd575f4e21096623bec4d2cf06ff4684d4342 $ git cat-file -p b1edd575f4e21096623bec4d2cf06ff4684d4342 # åç §å ãªãã¸ã§ã¯ãã®ä¸èº« tree 853e2b3e200f8c3d33badb87f225f7b46169fe2f parent 0f6f8dc6c0445b22bdc109ea6f25efc3eea84353 author m_hiyama 1443162784 +0900 committer m_hiyama 1443162784 +0900 second $
HEAD^ ã¨ããæ¸ãæ¹ã¯ãç¾å¨ã®HEADãæãã¦ããã³ãããã®è¦ªã³ãããï¼è¦ªãè¤æ°ãããªãã®1çªç®ã®è¦ªï¼ã表ãã¾ããä½ããè¦åãåºã¾ãããHEADã¯ç´æ¥çã«ããªãã¸ã§ã¯ãID b1edd575f4e21096623bec4d2cf06ff4684d4342 ã使ã£ã¦ãªãã¸ã§ã¯ããåç
§ããããã«ãªãã¾ãããåç
§å
ã®ãªãã¸ã§ã¯ãã¯ãsecond ã¨ã³ãããã¡ãã»ã¼ã¸ãããã³ããããªãã¸ã§ã¯ãã§ãï¼çµµ http://www.chimaira.org/img3/git-sample-1-whole-graph.pngãè¦ã¦ãã ããï¼ãgit checkout master
ã§å
ã®ç¶æ
ã«æ»ãã¾ãã
ç´æ¥åç §ã§ããéæ¥åç §ã§ãããHEADã®æããã®ã¯ï¼
- æã ãããããã¨ã«ä½æ¥ãããã³ããããªãã¸ã§ã¯ã
ã§ãã
ã©ãã«ã®è¿½å ã¨åé¤ã¯ãã©ãã§ãããç¨ã«è»½ãä½æ¥
å¤åå¯è½ãªã©ãã«ãã¤ã¾ããã©ã³ããä½ã£ã¦ã¿ã¾ãã
$ git branch b1 HEAD # ã©ãã«b1ã¯HEADã¨åããªãã¸ã§ã¯ããæã $ git branch b2 HEAD^ # ã©ãã«b2ã¯HEADã®è¦ªãªãã¸ã§ã¯ããæã $ git branch b3 topic # ã©ãã«b3ã¯topicã¨åããªãã¸ã§ã¯ããæã # 以ä¸çç¥ # ... $ ls .git/refs/heads/ # ã©ãã«ã®å®ä½ã§ãããã¡ã¤ã«ãåæ ./ b1 b11 b13 b15 b17 b19 b20 b4 b6 b8 master ../ b10 b12 b14 b16 b18 b2 b3 b5 b7 b9 topic $
20åã®ãã©ã³ãï¼ã©ãã«ï¼ãä½ã£ã¦ã¿ã¾ãããSourceTreeã§è¦ã¦ã¿ã¾ãã
4åã®ã³ããããªãã¸ã§ã¯ãã«ã©ãã«ãã¦ã¸ã£ã¦ã¸ã£ä»ãã¦ã¾ããå¥ã«åé¡ããã¾ããã
鬱é¶ããã£ããåé¤ãã¡ããã¾ããããgit branch -d b1
ã®ããã«ãã¾ããrm .git/refs/heads/b*
ãªãã¦ãè¡åã®æªããã¨ã¯ããªãã§ãã
ããããåããããã«ããã©ã³ãï¼ã©ãã«ï¼ãä½ã£ã¦ãæ¶ãã¦ãããªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã«ã¯ä½ã®å½±é¿ãããã¾ããããã ããHEADããæããã¦ããã«ã¬ã³ããã©ã³ãã¯æ¶ãã¾ããããã®ä»ããã©ã³ãåé¤ã§ãããã®ãããã¨è¦åãããã±ã¼ã¹ãããã¾ãã
åºå®ã©ãã«ã§ããã¿ã°ã«é¢ãã¦ãåããã¨ã§ããããä½ã£ã¦ãæ¶ãã¦ããã¾ãã¾ãããã¿ã°ã«ã¯ãã©ã³ãã®ãããªåé¤å¶éã¯ããã¾ããã
æ¶ãã¹ãã§ãªãã©ãã«ãééã£ã¦æ¶ããã¹ã¯èµ·ããå¾ãã§ããããããããããã¯Gitã®ã¡ã«ããºã ã®åé¡ã§ã¯ãªãã¦ã人éã®æ³¨æåã®åé¡ã§ãã注æã¯å¿ è¦ã§ããããã©ã³ãï¼ã¿ã°ã¯æ¥µãã¦ãæ軽ãªéå ·ã§ãã
ãã©ã³ããã¿ã°ãé£ãããªãã®ã¯ãããã¸ã§ã¯ããçµç¹ã¨ãã¦ã®éç¨ã«ã¼ã«ãä½ã£ããå®ã£ãããã段éã«ããã¦ã§ããGitã®ãã©ã³ãï¼ã¿ã°ã¯åç´è»½éãªã¡ã«ããºã ã§ãããè¯ã使ãæ¹ãé£ããã®ã§ãã
å¤æ ãªãã¸ããªç»å ´
ãã©ã³ãã®æ¦å¿µãããã«æ¢ãããã«ãå¤æ ãªãªãã¸ããªãä½ãã¾ããããã§å¤æ ã¨è¨ã£ã¦ããã®ã¯ãã³ãããã°ã©ãããèªç¶ã«ã¯ãªããªãç¾ããªããããã¸ã¼ï¼ç¹ããå ·åï¼ããã¦ããããã§ãã
git-quest-kit.sharãå±éãããªãã®ãsetup-git-sample-3.sh ã使ãã¾ããã¹ã¯ãªããã®çªå·ã¯3çªã§ããsetup-git-sample-2.sh ã§ã¯ãªãã®ã§ã注æã
$ cd .. # 1-git-sample/ ããä¸ã«æ»ã $ sh ./setup-git-sample-3.sh ãªã«ãããã«ãã $
2çªã®ã¹ã¯ãªãã setup-git-sample-2.sh ã¯ããªã¢ã¼ããªãã¸ããªããã§ããããªã¢ã¼ãã¨ã®ãã¼ã¸ãªã©ã®èª¬æãããããã«æºåãããã®ã§ããè¨äºãé·ããªã£ã¦ãã¾ã£ãã®ã§ããã®é¨åã®èª¬æã¯ä»åå²æãã¾ããããã¯ãã¾ãã®æ©ä¼ã«è¿°ã¹ãããç¥ãã¾ããï¼1å¹´ååã¨åãã»ãªãï¼ã
åºæ¥ä¸ãã£ããªãã¸ããªãSourceTreeã§è¦ã¦ã¿ã¾ãã
ãã®ãªãã¸ããªãä½ãããã«ãåãäºåã«æããâè¨è¨æ¸âã次ã®çµµã§ãã
ãããªãªãã¸ããªãä¾é¡ã«ããã®ã¯ãå¹¹ã ã®æã ã®ã¨ããå å ¥è¦³ãç ´å£ãããã£ãããã§ãã
ã³ãããã®çªå·ã¯ãã³ãããã¡ãã»ã¼ã¸ã使ã£ã¦å ¥ãã¦ãã¾ãã説æã«ã¯ãã®çªå·ã使ãã¾ããã§ããGitã¯çªå·ãç解ããªãã®ã§ãçªå·ã¨Gitã®åç §å¼ï¼æ£ç¢ºã«ã¯ãrevision expressionã¨è¨ãã¾ãï¼ã®å¯¾å¿ã示ãã¦ããã¾ãã
ã³ãããã®çªå·ï¼èª¬æç¨ï¼ | Gitã®åç §å¼ |
---|---|
1 | master^^ |
2 | master^ |
3 | master |
4 | HEAD^ |
5 | HEAD |
6 | tag_master2 |
7 | other^ |
8 | other |
ä¾ãã°ã4çªã®ã³ããããè¦ãããªããgit show -s HEAD^
ã¨ãã¾ãã
$ cd 3-git-sample/ $ git show -s HEAD^ commit d293eb0cfb3e979c9d3bf83ff8d38e192de75d0f Author: m_hiyamaDate: Sat Sep 26 13:06:45 2015 +0900 4 $
AOSéåã¯ç解ãã¦ãã
ããããã¯ãææãã®ã°ã©ãã®çµµ http://www.chimaira.org/img3/git-hentai-repo-plan.png ãè¦ãªãããããã¦ç·´ç¿åé¡ã解ãã¤ããã§èªãã§ãã ããã
ææãã®ã³ãããã°ã©ãã¯ãä¸æ¹åã«ç¥å ãä¸æ¹åã«åå«ã¨ãªãããã«æãã¦ãã¾ããç¹å®ã®ã³ããããæå®ããã¨ãããã®ã³ãããã®ç¥å ã³ãããå ¨ä½ãããªããã¼ãéåããç¥å éåï¼ancestor node-setï¼ã¨å¼ã³ã¾ããèªåèªèº«ï¼å½è©²ã³ãããï¼ãå«ããéåã¯ãèªåãå«ãç¥å éåï¼ancestor-or-self node-setï¼ã§ããancestor-or-selfã¯XPathã®ç¨èªã§ãããé·ããããã®ã§AOSéåã¨ç¥ç§°ãã¾ãããã
ç¹å®ã®ã³ãããã®AOSéåãããã©ã³ãï¼ã©ãã«ä»¥å¤ã®æå³ï¼ãç解ããããã§æ¥µãã¦éè¦ã§ããAOSéåã使ããã«ãææ§ãªå©ã話ã®ãããªäºã°ããè¨ã£ã¦ãã¦ãã©ããããã¾ãããAOSéåãã¡ããã¨ç解ãã¾ãããï¼
ä¾é¡ã®å¤æ ã³ãããã°ã©ãã«ããã¦ãï¼çªã®ãã¼ãï¼ã³ããããªãã¸ã§ã¯ãï¼ã®AOSéåã AOS(1) ã¨æ¸ããã¨ã«ãã¾ããAOS(2), AOS(3), ... ãªã©ãåãã§ããï¼çªããï¼çªã¾ã§ã®ãã¹ã¦ã®ãã¼ãï¼ã³ããããªãã¸ã§ã¯ãï¼ã«é¢ã㦠AOS(n) ãæ±ãã¦ãã ããã
ãã£ã¦ãã ãããã
ããã¾ãããï¼
æåã®3ã¤ã® AOS(n) ã ããæ¸ãã¦ããã°ï¼
- AOS(1) = {1}
- AOS(2) = {1, 2}
- AOS(3) = {1, 2, 3, 4}
ããã©ã³ããã¨ããè¨èãâã³ããããªãã¸ã§ã¯ãã®éåâã®æå³ã§ä½¿ãããã¨ãã¯ãç¹å®ã³ãããã®AOSéåã®ãã¨ã§ãã
ä¾ãã°ãmasterãã©ã³ãã¯ãã©ãã«masterãæãã³ãããã3çªãªã®ã§AOS(3)ãã¤ã¾ã4åã®ã³ããããããªãéå {1, 2, 3, 4} ã®ãã¨ã§ããotherãã©ã³ããªã AOS(8) = {7, 8} ã¨ãªãã¾ãã
AOSéåãGitã«è¡¨ç¤ºããã
ç¹å®ã³ãããã«å¯¾ããAOSéåã表示ããã³ãã³ãã git log ã§ããgit log ã¯è©³ããæ å ±ã表示ãã¾ãããä»åã¯çªå·ã ãã表示ãããããã«ãgit log --format=%s ã¨ããå½¢ã使ãã¾ãã
$ git log --format=%s master^^ # AOS(1) 1 $ git log --format=%s master # AOS(3) 3 2 4 1 $ git log --format=%s HEAD # AOS(5) 5 4 $ git log --format=%s tag_master2 # AOS(6) 6 5 2 4 1 $ git log --format=%s other # AOS(8) 8 7 $
AOSéåã®å ±éé¨åéå
2ã¤ã®éåã®å ±éé¨åéåã¨ããã®ãããã¾ãï¼Wikipediaé ç®ï¼ã次ã®å³ï¼ãã³å³ï¼ã§è¡¨ç¾ããã¾ãã
2ã¤ã®AOSéåã®å ±éé¨åã¯ã2ã¤ã®ã³ãããã®å ±éç¥å éåã§ããå ±éç¥å éåã¯ç´ç·ç¶ã ã¨æã£ã¦ãã人ããã¾ããããããªãã¨ã¯ãªãã§ããã
- 3çªã³ãããã¨6çªã³ãããã®å ±éç¥å éå㯠{1, 2, 4} ã§ãç´ç·ç¶ã§ã¯ããã¾ããã
- 2çªã³ãããã¨5çªã³ãããããããã¯6çªã³ãããã¨8çªã³ãããã®å ±éç¥å éåã¯ç©ºéåã§ãã
Gitã®ãã¼ã¸ã¢ã«ã´ãªãºã ã¯ãå ±éç¥å ã³ãããï¼ãã¼ã¸ãã¼ã¹ã¨å¼ã¶ï¼ã®åå¨ãä»®å®ãã¦ã¾ããããªãã¦ãåãã¾ã*11ãä¸çªè¥ãå ±éç¥å ã³ããããä¸æã«æ±ºã¾ã£ãã»ããæã¾ãããã¨ã¯è¨ãã¾ããã©ã*12ã
Gitã使ã£ã¦ããéåæ¼ç®ï¼å·®éåã¨å¯¾ç§°å·®éå
éåã®å ±éé¨åãã¨ãæ¼ç®ã¯ããç¥ãããéåæ¼ç®ã§ãããGitã¯ãå ±éé¨åããç¥å度ãä½ãéåæ¼ç®ã§ããå·®éåã¨å¯¾ç§°å·®éåã使ãã¾ãã
å·®éåã¨å¯¾ç§°å·®éåããã³å³ã§æãã°æ¬¡ã®ããã§ããç¥ããªãã£ã人ã¯ãç´åã®æ®µè½å ãããªã³ã¯ãå¼µã£ãWikipediaé ç®ã調ã¹ã¦ãã ããã
å®ã¯ããæãã¨ããæ¦å¿µã表ç¾ããã«ã¯ãå·®éåã¨å¯¾ç§°å·®éåãå¿ è¦ãªã®ã§ãã
å·®éåã®æ¼ç®è¨å·ããï¼¼ãã対称差éåã®æ¼ç®è¨å·ããâ³ãã¨ç´æãã¾ããä¾é¡ã®å¤æ ãªãã¸ããªã«é¢ãã¦ã次ã®éåãæ±ãã¦ãã ãããï¼çµµâ http://www.chimaira.org/img3/git-hentai-repo-plan.png ï¼
- AOS(3)ï¼¼AOS(6)
- AOS(3)â³AOS(6)
- AOS(6)ï¼¼AOS(2)
- AOS(6)â³AOS(2)
- AOS(6)ï¼¼AOS(8)
- AOS(6)â³AOS(8)
ä»ãçãããã¯ãã¾ãããæ£è§£ã¯ãGitã«æãã¦ãããã¾ãããã
ãã®éåæ¼ç®ãçã¯Gitã«èã
Gitã§ã¯ãæå®ãã2ã¤ã®ã³ãããã«å¯¾ãã¦ï¼
- 2ã¤ã®AOSéåã®å·®éåãæ±ããæ¼ç®ãã..ãï¼ããã2ã¤ï¼ããã ãéé
- 2ã¤ã®AOSéåã®å¯¾ç§°å·®éåãæ±ããæ¼ç®ãã...ãï¼ããã3ã¤ï¼
ã§è¡¨ããã¨ã«ãªã£ã¦ãã¾ãããéé ãã¨ã¯ãAOS(3)ï¼¼AOS(6) ãæ±ããã®ã« 6..3 ã¨æ¸ãã¨ãããã¨ã§ãã対称差éåã¯é çªã«ç¡é¢ä¿ï¼å¯ææ¼ç®ï¼ã§ãã
ã§ããããåã»ã¯ã·ã§ã³ã®ç·´ç¿åé¡ãGitè¨æ³ã«æ¸ãæããã°æ¬¡ã®ããã«ãªãã¾ãã
- 6..3 ï¼éé ï¼
- 3...6
- 2..6 ï¼éé ï¼
- 6...2
- 8..6 ï¼éé ï¼
- 6...8
Gitã¯ã³ãããã®çªå·ãç解ãã¾ãããããå ã»ã©ã®ãçªå·ââåç §å¼ãå¤æ表ã®å¿ è¦ãªé¨åãåæ²ãã¾ãã
ã³ãããã®çªå·ï¼èª¬æç¨ï¼ | Gitã®åç §å¼ |
---|---|
2 | master^ |
3 | master |
6 | tag_master2 |
8 | other |
ããã§æºåOKãéåæ¼ç®ã®çãGitã«æãã¦ãããã¾ãããã
$ git log --format=%s tag_master2..master # 6..3 3 $ git log --format=%s master...tag_master2 # 3...6 3 6 5 $ git log --format=%s master^..tag_master2 # 2..6 6 5 4 $ git log --format=%s tag_master2...master^ # 6...2 6 5 4 $ git log --format=%s other..tag_master2 # 8..6 6 5 2 4 1 $ git log --format=%s tag_master2...other # 6...8 6 5 8 2 4 7 1 $
ããä¸åº¦ãhttp://www.chimaira.org/img3/git-hentai-repo-plan.png ã®çµµã¨è¦æ¯ã¹ã¦ãã ãããGitã¯ã¡ããã¨éåæ¼ç®ããã£ã¦ãã§ããã
ãã£ã¨ãæãã®æ¦å¿µã«ãã©ãçããã
ä¸è¦åããã«ããæ¼ç®è¨å·ã..ãã...ãã§ããããããå©ç¨ããã°ã³ãããã°ã©ãã®ä¸é¨ããã¾ãæå®ã§ãã¾ããç¹ã«ãå¤å ¸çã»ä¼çµ±çãªãæãæ¦å¿µã表ç¾ã§ããã®ã§ãã
éçºã®ã¡ã¤ã³ã©ã¤ã³ã§ããå¹¹ããæåãããããæããã³ãããéåï¼ã³ãããã°ã©ãã®ãã¼ãã»ããï¼ã¨ãã¦è¡¨ç¾ãããã¨ãèãã¾ããå¹¹ã®å é ã®ã³ããããMãæã®å é ã®ã³ããããBã¨ãã¾ãããã
ãã®ã³ãããã°ã©ãã«ããã¦ãå·®éå M..B = AOS(B)ï¼¼AOS(M) ã¨ã対称差éå B...M = M...B = AOS(B)â³AOS(M) ãæ±ããã°æ¬¡ã®ããã«ãªãã¾ãã
å¾ãããã³ãããéåã¯ã確ãã«ãæãã¨å¼ã¶ã«ãµãããããã®ã§ããããããããã¾ã§é å¼µã£ã¦èªãã§ããããçããã«ã¯ãã©ãã«ã¨ãã¦ã®ããã©ã³ããããæã¨ãã¦ã®ããã©ã³ããã¾ã§ã®éã®ãã¯ãéåã¨é ããã¨ãç解ã§ããã¯ãã§ãã
ãããªã«ãé£ããæ¦å¿µããã¾ã¨ããªèª¬æãããªãã§ããã©ã³ãã¯æã§ããã¨ãè¨ã£ã¦ãã¾ãææ°ãã£ã¦ãã¤ã«ã¬ãã¢ãã«ï¼ ã¨åã¯è ¹ç«ãããã®ã§ããã
Gitãèªä¿¡ãæã£ã¦ä½¿ãããã«ãããã©ã³ãããã¡ããã¨ç解ãã¾ããããã
æé·ç¹ã¨ãã¦ã®ãã©ã³ã
ããã©ã³ãç·¨ãã大詰ãã§ããç²ããæ¹ã¯ä¸æ¯å ¥ãã¾ãããã
ã©ãã«ã¨ãã¦ã®ãã©ã³ãã¯ãå¤åããã©ãã«ã ã¨è¨ãã¾ãããã§ã¯ãã©ã®ããã«å¤åããã®ã§ããããããã®å¤åã®ã«ã¼ã«ãç¥ããªãã¨ããã©ã³ãï¼ã©ãã«ï¼ã®æåãç解ã»äºæ¸¬ã§ãã¾ããã
ãã©ã³ãã©ãã«ã®æåãç解ããåã«ãHEADã©ãã«ã«ã¤ãã¦ç¥ã£ã¦ããå¿ è¦ãããã¾ããHEADã¯ãç´æ¥çã¾ãã¯éæ¥çã«ã«ã¬ã³ãã³ããããåç §ãã¾ããHEADãã©ããªã³ããããæããã¯èªç±ã§ãããHEADã¯ææ°ã®ã³ããããæããã¨ãã¯åï¼ç©ããã«è¨ã£ã¦ãè¨èã®ãããï¼ã§ãããä¿¡ç¨ããªãããã«*13ã
ãªãã¸ã§ã¯ãã°ã©ãã®é¨åã°ã©ãã§ããã³ãããã°ã©ãã«ãã¼ãï¼ã³ããããªãã¸ã§ã¯ãï¼ã追å ããã¨ããæ°ãããã¼ãã®è¦ªã¯å¿ ãHEADãæãã³ãããã«ãªãã¾ããè¨ãæ¹ãå¤ããã¨ã追å ããããã¼ãã¯HEADã®åãã¼ãã¨ãªãã¾ããã°ã©ãã¯ãHEADãæãã³ãããã®æããæé·ãããã¨è¨ãã¾ãã
ã³ãããã°ã©ãã«æ°ãããã¼ãï¼ã³ããããªãã¸ã§ã¯ãï¼ã追å ãããã¨ãHEADã©ãã«ã¯æ°ãããã¼ããæãããã«æ¸ãæãããã¾ãã
HEADã«é¢ããååï¼
- 追å ããããã¼ãã¯ãç¾å¨ã®ãHEADãæããã¼ããã®åãã¼ãã¨ãªãã
- 追å ãå®äºããã¨ãHEADã¯æ°ãããã¼ããæãããã«æ¸ãæããããã
以ä¸ã¯ãHEADã©ãã«ãç´æ¥ã«ãã¼ãï¼ã³ããããªãã¸ã§ã¯ãï¼ãåç §ããç¶æ³ãæ³å®ãã¦ã¾ããããHEADã©ãã« â ãã©ã³ãã©ãã« â ã³ããããªãã¸ã§ã¯ããã®å ´åã§ããåãååãé©ç¨ããã¾ãã
- 追å ããããã¼ãã¯ãç¾å¨ã®ãHEADãæããã©ã³ããæããã¼ããã®åãã¼ãã¨ãªãã
- 追å ãå®äºããã¨ããHEADãæããã©ã³ããã¯æ°ãããã¼ããæãããã«æ¸ãæããããã
ããã§èª¬æã¯çµããã§ããããã ãç解ããã°ååã§ããã¤ã¾ããªãå©ã話ãææ§ãªèª¬æã¯å¿ãã¾ãããã
ç¾å®ã®ã±ã¼ã¹ã§ã¯ãHEADã©ãã«ã¯ãã©ã³ãã©ãã«ãæãã¦ãã¾ãããã®ãããæ°ãããã¼ãï¼ã³ããããªãã¸ã§ã¯ãï¼ã®è¿½å ã®éã«ãHEADèªä½ãæ¸ãæããå¿ è¦ã¯ãªãã¦ããã©ã³ãã©ãã«ãæ´æ°ããã¾ããããã§ããHEADã«é¢ããååã¯ããã³ã¨å®ããã¾ãã
HEADãæãã³ããããã³ãããã°ã©ãã®æé·ç¹ã§ãããHEADããã®åç §ããã©ã³ããçµç±ããã¨ãã¯ããHEADãæããã©ã³ããæãã³ãããããæé·ç¹ã¨ãªãã¾ããã¤ã¾ããã«ã¬ã³ããã©ã³ããã³ãããã°ã©ãã®æé·ç¹ãã¨è¨ã£ã¦ãããããã§ãã
ãHEADãæããã©ã³ãããæ¸ãæãããã¨ãããã©ã³ããåãæ¿ãããã¨è¨ã£ãããã¾ãããã©ã³ãã®åãæ¿ãã¯ãã©ãã«ã®æ¸ãæãã ãã§ã¯æ¸ã¾ãªãã¦*14ãcheckoutã«ããä½æ¥ãã£ã¬ã¯ããªï¼ã¯ã¼ã¯ããªã¼ï¼ã®æ´æ°ãçãã¾ãããåç §ã·ã¹ãã ã¨ãã¦ã®æåã¯ä»è¿°ã¹ãã¨ããã§ãã
æåã°ã©ãã®ã¯ã¤ãº
ããã§ç·´ç¿åé¡ -- ã¤ããããGitã使ã£ããéã³ã§ããä»å説æããªãã£ããã§ããããã¼ã¸ã使ãã¾ãããã§ããï¼ãã¼ã¸ããåç¥ã®æ¹ã¯ãã£ã¬ã³ã¸ãã¦ã¿ã¦ãã ããã[追è¨]ãã§ããã¯ä½¿ããªãã¦ãåºæ¥ã¾ããããã®æ¹æ³ã¯ãææ¸using-orphan.mdãåç §ãã¦ä¸ããã[/追è¨]
æåã°ã©ãã«ããã¦ãæå辺ï¼ç¢å°ï¼ãâæµãâã¨è§£éããã¨ãã次ã®ãããªç¨èªã使ãã¾ãã
ãã¼ãã®åé¡ | å ¥ã辺ã®æ° | åºã辺ã®æ° |
---|---|---|
湧ãåºããã¼ã | 0 | ä»»æ |
å¸ãè¾¼ã¿ãã¼ã | ä»»æ | 0 |
åæµãã¼ã | 2ä»¥ä¸ | ä»»æ |
åæµãã¼ã | ä»»æ | 2ä»¥ä¸ |
å ¥ã辺ã®æ°ãåºã辺ã®æ°ã 0, 1, 2 ã«å¶éãã¦ããã¹ã¦ã®çµã¿åãããåæãã¦ã¿ã¾ãã
å ¥âåºâ | 0 | 1 | 2 |
0 | 湧ãåºãï¼å¸ã込㿠| 湧ãåºã | 湧ãåºãï¼åæµ |
1 | å¸ã込㿠| åæµ | |
2 | åæµï¼å¸ã込㿠| åæµ | åæµï¼åæµ |
9種é¡ã®ãã¼ãã«ãªãã¾ããã
9åã®ãã¼ããæã¤æåã°ã©ãã§ããã®ããã®ãã¼ããä¸ã®è¡¨ã®ããããã®ç¨®é¡ã®ãã¼ãã«ãªããããªãã®ãæãã¦ã¿ã¦ãã ããããã°ãã試è¡é¯èª¤ããã°åºæ¥ãã¨æãã¾ããã
次ã«ããã®æåã°ã©ããGitã®ã³ãããã°ã©ãã¨ãã¦å®ç¾ãã¦ã¿ã¦ã¾ããããã©ããªgitã³ãã³ãã使ã£ãããããåãããªã人ã¯ãå¤æ ãªãã¸ããªãä½ãã¹ã¯ãªããsetup-git-sample-3.shãè¦ãã°ãã³ãã«ãªãã§ãããã
è¨ãæ®ããäºãªã©
Gitã¯èªç±åº¦ã®é«ãã½ããã¦ã§ã¢ã§ããèªç±åº¦ãé«éããã¨ãè¨ãã¾ããã§ãããããæ®éããããªãã¨ããã¼ããã¨ããããããã¶ãªãããã¨ããæä½ã»æ©è½ã¯å¤ã ããã¾ããGitèªèº«ãæå¤ã¨è¦ªåã«è¦åãã¦ããã¾ããããããªãããéç¨ä¸ã®æ¨å¥¨äºé ã»æ³¨æäºé ã¨ã¡ã«ããºã ã»æ©è½æ§ã®å¢çãææ§ã«ããã®ã¯è¯ããªãã¨æãã¾ãããã®è¨äºããå§ãã¦ãå¤æ ã»å¤éãªGit使ãã«ããªããã§ãããããããã¯çããã®è¯èã§å¤æã§ããã¯ãã§ãã
ä»åã¯ãGitã®ãªãã¸ã§ã¯ããã¼ã¿ãã¼ã¹ã¨åç §ã·ã¹ãã ã«ã¤ãã¦ã ã説æãã¾ãããä»ã«ããªãã¸ããªã¸ã®å ¥åºåãå¸ããµãã·ã¹ãã ããããã³ãã³ãã©ã¤ã³ã¤ã³ã¿ã¼ãã§ã¤ã¹ãæ§æããããããã®ãµãã³ãã³ãï¼ãªãã·ã§ã³ãããã¾ããã¯ã¼ã¯ããªã¼ãã¤ã³ããã¯ã¹ï¼ã¹ãã¼ã¸ã³ã°ã¨ãªã¢ï¼ããªã¢ã¼ããªãã¸ããªããµãã¢ã¸ã¥ã¼ã«ãªã©ã«ã¤ãã¦ã¯ãã詳ãããã¨ã¯ã¾ãã®æ©ä¼ã«è¿°ã¹ãããç¥ãã¾ãããã¨ããè¨èãåã³æ¸ãã¦ããã¾ãã
ãã®è¨äºããå£éè¦ããããã«ãæåéå·¡åã°ã©ãï¼directed acyclic graphï¼ã®è«¸æ¦å¿µã¯ããªãã¸ã§ã¯ãã°ã©ãã®è°è«ã«å¹æçã«é©ç¨ã§ãã¾ããã°ã©ãçè«ã®è¦³ç¹ããè¦ãGitã¨ããã®ãé¢ç½ã話é¡ããç¥ãã¾ããã
ã°ã©ããã¼ã¿ãã¼ã¹ã·ã¹ãã ã¨ãã¦ã®Gitã¨ã¯ã©ããªããã ããï¼ ã¨ãããããï¼å·®åï¼ã¨Gitã¨ã®é¢ä¿ã¨ããåã«ã¯èå³æ·±ã話ã§ããè²ã ã¨è©±é¡ã¯å°½ãã¾ãããããããã¸ãã«ãã¦ããã¾ãã
*1:ã¢ãã ã¨ã¤ãã¨ç¦æã®æå®ã®ã話ã«ãã¤ãã¸ã¯ã®èã£ã±ãåºã¦ãã¾ãã
*2:å¹´å¯ãããç¥ããªã話ãããã¤ãã£ã¢ ã¹ããã¡ãã¼âæ¦ç°ä¹ ç¾ååçéãã¯ãããã¯ã¹ (1989/09)åç §ã
*3:ãã£ã³ãã¬ããï¼Jacopo Tintorettoï¼ã«ãããµããããªã¤ãï¼çµµç»ã®ä¸é¨ï¼ãç»åã®åå¾å ï¼ http://transact.seesaa.net/article/104243331.html
*4:ããã¤ããªãã£ã¦ä½ã ãï¼ ã£ã¦è©±ã¯æ¯åº¦åºããã§ããã人éå¯èªã§ã¯ãªããã©ã¼ãããã®ãã¼ã¿ã¨ããç¨åº¦ã§ãã
*5:ã¨ã«ããæããå®æãããç»åã®åå¾å ï¼ http://earth38moon.blog115.fc2.com/blog-entry-3159.html
*6:ããã¯ããããªãã¸ã§ã¯ããèæ ®ãã¦ã¾ããã
*7:ããããx.txtã¯ã©ããããåç §ãããªãè¿·åãªãã¸ã§ã¯ãã«ãªã£ã¦ãã¾ããgit fsck ã§ç¢ºèªã§ãã¾ãã
*8:git reflog ã§è¦ã¤ããã¾ãã
*9:[追è¨]ãã®è¡¨ã®é·ããªãã¸ã§ã¯ãIDãå°ç»é¢ããã¤ã¹ã§ã®ã¬ã¤ã¢ã¦ããéªéãã¦ãããããªã®ã§ä¿®æ£ã[/追è¨]
*10:[追è¨]644ã755ã¯ãã¼ããã·ã§ã³ã«è¦ãã¾ããããã¼ããã·ã§ã³ãã®ãã®ã¨ããããã§ã¯ãªãã¦ã6æ¡å ¨ä½ã§ãªãã¸ã§ã¯ãã®åé¡ããã¦ããããã§ãã[/追è¨]
*11:git merge-base ã¯ãã©ããªå ´åã§ãä½ãããã®ã³ããããªãã¸ã§ã¯ããæ¢ãåºãã¾ãã
*12:[追è¨]2ã¤ã®ã³ãããã«å¯¾ãã¦ãä¸çªè¥ãå ±éç¥å ã³ããããä¸æã«æ±ºã¾ãã¨ããã³ãããã°ã©ãã¯é åºéåã¨ãã¦ï¼ãããã¯ä»£æ°æ§é ã¨ãã¦ï¼åæï¼semilatticeï¼ã¨å¼ã³ã¾ãã常èçãªãªãã¸ããªã¯åæã«ãªã£ã¦ã¾ãããåæã§ã¯ãªããªãã¸ããªã¯æ±ãã«ããã§ããåæãªãã¸ããªã§ã¯ãæåã®ã³ãããï¼ãããã¨ã®ç¥å ãå§ç¥ï¼ã¯1åã ãã§ãããããã£ã¦ãã³ãããã°ã©ãã®è¾ºã®åããå転ãããã°ã©ãã§ã¯ãä»»æã®ãã¼ãããå§ç¥ã³ãããããå¯éï¼reachableï¼ãã¨ãªãã¾ãã[/追è¨]
*13:ããããããææ°ããã©ãå®ç¾©ãããããããªããªãã§ããããã¿ã¤ã ã¹ã¿ã³ãã§æ¯è¼ããã®ããæåã°ã©ãã®ãããã¸ã¼ããå¤æããã®ãï¼
*14:git symbolic-refã³ãã³ãã§ãéæ¥åç §ã®æ¸ãæãã ããã§ãã¾ãã