-
6. GitHub
-
7. Git ã®ããŸããŸãªããŒã«
- 7.1 ãªããžã§ã³ã®éžæ
- 7.2 察話çãªã¹ããŒãžã³ã°
- 7.3 äœæ¥ã®é ããããšæ¶ããã
- 7.4 äœæ¥å 容ãžã®çœ²å
- 7.5 æ€çŽ¢
- 7.6 æŽå²ã®æžãæã
- 7.7 ãªã»ããã³ãã³ã詳説
- 7.8 é«åºŠãªããŒãžææ³
- 7.9 Rerere
- 7.10 Git ã«ãããããã°
- 7.11 ãµãã¢ãžã¥ãŒã«
- 7.12 ãã³ãã«ãã¡ã€ã«ã®äœæ
- 7.13 Git ãªããžã§ã¯ãã®çœ®ãæã
- 7.14 èªèšŒæ å ±ã®ä¿å
- 7.15 ãŸãšã
-
8. Git ã®ã«ã¹ã¿ãã€ãº
- 8.1 Git ã®èšå®
- 8.2 Git ã®å±æ§
- 8.3 Git ããã¯
- 8.4 Git ããªã·ãŒã®å®æœäŸ
- 8.5 ãŸãšã
-
9. Gitãšãã®ä»ã®ã·ã¹ãã ã®é£æº
-
10. Gitã®å åŽ
- 10.1 é 管ïŒPlumbingïŒãšç£åšïŒPorcelainïŒ
- 10.2 Gitãªããžã§ã¯ã
- 10.3 Gitã®åç §
- 10.4 Packfile
- 10.5 Refspec
- 10.6 転éãããã³ã«
- 10.7 ã¡ã³ããã³ã¹ãšããŒã¿ãªã«ããª
- 10.8 ç°å¢å€æ°
- 10.9 ãŸãšã
-
A1. ä»é² A: ãã®ä»ã®ç°å¢ã§ã®Git
- A1.1 ã°ã©ãã£ã«ã«ã€ã³ã¿ãã§ãŒã¹
- A1.2 Visual Studioã§Gitã䜿ã
- A1.3 Eclipseã§Gitã䜿ã
- A1.4 Bashã§Gitã䜿ã
- A1.5 Zshã§Gitã䜿ã
- A1.6 Powershellã§Gitã䜿ã
- A1.7 ãŸãšã
-
A2. ä»é² B: Gitãããªãã®ã¢ããªã±ãŒã·ã§ã³ã«çµã¿èŸŒã
-
A3. ä»é² C: Gitã®ã³ãã³ã
- A3.1 ã»ããã¢ãããšèšå®
- A3.2 ãããžã§ã¯ãã®ååŸãšäœæ
- A3.3 åºæ¬çãªã¹ãããã·ã§ãã
- A3.4 ãã©ã³ããšããŒãž
- A3.5 ãããžã§ã¯ãã®å ±æãšã¢ããããŒã
- A3.6 æ€æ»ãšæ¯èŒ
- A3.7 ãããã°
- A3.8 ãããã®é©çš
- A3.9 ã¡ãŒã«
- A3.10 å€éšã·ã¹ãã
- A3.11 ã·ã¹ãã 管ç
- A3.12 é 管ã³ãã³ã
8.1 Git ã®ã«ã¹ã¿ãã€ãº - Git ã®èšå®
ãããŸã§æ¬æžã§ã¯ãGit ã®åºæ¬åäœããã®äœ¿çšæ³ã«ã€ããŠæ±ã£ãŠããŸããããŸããGit ãããç°¡åã«å¹çãã䜿ãããã®ããŸããŸãªããŒã«ã«ã€ããŠã玹ä»ããŸããã æ¬ç« ã§ã¯ãéèŠãªèšå®é ç®ãããã¯ã·ã¹ãã ã䜿çšããŠãããã«ã¹ã¿ãã€ãºãããæ¹æ³ã§ Git ãæäœããæ¹æ³ã«ã€ããŠæ±ããŸãã ããããå©çšããã°ãã¿ãªããèªèº«ããã®å€åå ãæå±ã°ã«ãŒãã®ããŒãºã«ããããæ¹æ³ã§ Git ã掻çšã§ããããã«ãªãã§ãããã
Git ã®èšå®
[ch01-introduction] ã§æçã«ãããããã ããããã«ãgit config
ã³ãã³ã㧠Gitã®èšå®ãè¡ããŸãã
æåã«ããããšãšèšãã°ãååãšã¡ãŒã«ã¢ãã¬ã¹ã®èšå®ã§ãããã
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
ããã§ã¯ãåãããã«ããŠèšå®ã§ããããèå³æ·±ãé ç®ãããã€ã身ã«ã€ããGit ãã«ã¹ã¿ãã€ãºããŠã¿ãŸãããã
ãŸããç°¡åã«ããããããŸããããGit ã§ã¯ãããã€ãã®èšå®ãã¡ã€ã«ã䜿ã£ãŠããã©ã«ã以å€ã®æåãå®çŸ©ããŸãã
æåã« Git ãèŠãã®ã¯ /etc/gitconfig
ã§ãããã«ã¯ã·ã¹ãã äžã®å
šãŠãŒã¶ãŒã®å
šãªããžããªåãã®èšå®å€ãèšè¿°ããŸãã
git config
ã«ãªãã·ã§ã³ --system
ãæå®ãããšããã®ãã¡ã€ã«ã®èªã¿æžããè¡ããŸãã
次㫠Git ãèŠãã®ã¯ ~/.gitconfig
ïŒãŸã㯠~/.config/git/config
ïŒã§ãããã¯åãŠãŒã¶ãŒå°çšã®ãã¡ã€ã«ã§ãã
Git ã§ãã®ãã¡ã€ã«ã®èªã¿æžããããã«ã¯ã--global
ãªãã·ã§ã³ãæå®ããŸãã
æåŸã« Git ãèšå®å€ãæ¢ãã®ã¯ãçŸåšäœ¿çšäžã®ãªããžããªã®èšå®ãã¡ã€ã« (.git/config
) ã§ãã
ãã®å€ã¯ããã®ãªããžããªã ãã§æå¹ãªãã®ã§ãã
ãããã® âã¬ãã«â ïŒã·ã¹ãã ãã°ããŒãã«ãããŒã«ã«ïŒã®éã§ã¯ãããããåŸããèªãã å€ããã®åã®å€ãäžæžãããŸãããããã£ãŠãããšãã° .git/config
ã«æžããå€ã¯ /etc/gitconfig
ã§ã®èšå®ãããåªå
ãããŸãã
泚èš
|
Git ã®èšå®ãã¡ã€ã«ã¯ãã¬ãŒã³ããã¹ããªã®ã§ããããã®ãã¡ã€ã«ãæåã§ç·šéããæ£ããæ§æã§å
容ãè¿œå ããããšã§ãäžèšã®ãããªèšå®ãè¡ãããšãå¯èœã§ãããé垞㯠|
åºæ¬çãªã¯ã©ã€ã¢ã³ãã®ãªãã·ã§ã³
Git ã®èšå®ãªãã·ã§ã³ã¯ãããããäºçš®é¡ã«åé¡ã§ããŸããã¯ã©ã€ã¢ã³ãåŽã®ãªãã·ã§ã³ãšãµãŒããŒåŽã®ãªãã·ã§ã³ã§ãã 倧åã®ãªãã·ã§ã³ã¯ãã¯ã©ã€ã¢ã³ãåŽã®ãã®ãã€ãŸãå人çãªäœæ¥ç°å¢ãèšå®ããããã®ãã®ãšãªããŸãã 倧éã®ãæ¬åœã«å€§éã® ãªãã·ã§ã³ã䜿çšã§ããŸãããããã§ã¯ããã£ãšãäžè¬çã§ããã£ãšããã䜿ãããŠãããã®ã ããåãäžããŸãã ãã®ä»ã®ãªãã·ã§ã³ã®å€ãã¯ç¹å®ã®å Žåã«ã®ã¿æçšãªãã®ãªã®ã§ãããã§ã¯æ±ããŸããã Git ã§äœ¿ãããã¹ãŠã®ãªãã·ã§ã³ãç¥ãããå Žåã¯ã次ã®ã³ãã³ããå®è¡ããŸãããã
$ man git-config
ãã®ã³ãã³ãã¯ãå©çšã§ãããã¹ãŠã®ãªãã·ã§ã³ããç°¡åãªèª¬æãšãšãã«äžèŠ§è¡šç€ºããŸãã ãã®å 容ã¯ã http://git-scm.com/docs/git-config.html ã«ãããªãã¡ã¬ã³ã¹ã§ãèŠãããšãã§ããŸãã
core.editor
ããã©ã«ãã§ã¯ãã³ããããã¿ã°ã®ã¡ãã»ãŒãžãç·šéãããšãã«ã¯ããŠãŒã¶ãŒãããã©ã«ããšãã£ã¿ãšããŠèšå®ãããšãã£ã¿ïŒ $VISUAL
ãŸã㯠$EDITOR
ïŒã䜿ãããŸããããã©ã«ããšãã£ã¿ãèšå®ãããŠããªãå Žå㯠vi ãšãã£ã¿ã䜿ãããŸãã
ãã®ããã©ã«ãèšå®ãå¥ã®ãã®ã«å€æŽããã«ã¯ core.editor
ãèšå®ããŸãã
$ git config --global core.editor emacs
ããã§ãã·ã§ã«ã®ããã©ã«ããšãã£ã¿ã«é¢ä¿ãªããGit ã§ã¡ãã»ãŒãžãç·šéããéã«ã¯ Emacs ãèµ·åãããããã«ãªããŸããã
commit.template
ã·ã¹ãã äžã®ãã¡ã€ã«ãžã®ãã¹ãããã«èšå®ãããšãGit ã¯ãã®ãã¡ã€ã«ãã³ãããæã®ããã©ã«ãã¡ãã»ãŒãžãšããŠäœ¿ããŸãã
ããšãã°ã次ã®ãããªãã³ãã¬ãŒããã¡ã€ã«ãäœã£ãŠ ~/.gitmessage.txt
ã«ããããšããŸãããã
subject line
what happened
[ticket: X]
git commit
ã®ãšãã«ãšãã£ã¿ã«è¡šç€ºãããããã©ã«ãã¡ãã»ãŒãžãããã«ããã«ã¯ãcommit.template
ã®èšå®ãå€æŽããŸãã
$ git config --global commit.template ~/.gitmessage.txt
$ git commit
ãããšãã³ãããã¡ãã»ãŒãžã®é圢ãšããŠãã®ãããªå 容ããšãã£ã¿ã«è¡šç€ºãããŸãã
subject line
what happened
[ticket: X]
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/test.rb
#
~
~
".git/COMMIT_EDITMSG" 14L, 297C
ã³ãããã¡ãã»ãŒãžã«ã€ããŠããŒã å ã«æå®ã®æ±ºãŸããããã®ãªãããã®æ±ºãŸãã«åŸã£ããã³ãã¬ãŒããã·ã¹ãã äžã«äœã£ãŠ Git ã«ããã䜿ãããããã«ãããšããã§ããããããããã°ããã®æ±ºãŸãã«åŸã£ãŠãããããããªããŸãã
core.pager
core.pager ã¯ãGit ã log
ã diff
ãªã©ãåºåãããšãã«äœ¿ãããŒãžã£ãèšå®ããŸãã
more
ãªã©ã®ã奜ã¿ã®ããŒãžã£ãèšå®ããã (ããã©ã«ã㯠less
ã§ã)ã空æååãèšå®ããŠããŒãžã£ã䜿ããªãããã«ãããã§ããŸãã
$ git config --global core.pager ''
ãããå®è¡ãããšããã¹ãŠã®ã³ãã³ãã®åºåããã©ããªã«é·ããªã£ããšããŠãå šéš Git ãåºåããããã«ãªããŸãã
user.signingkey
眲åå ¥ãã®æ³šéä»ãã¿ã° (äœæ¥å 容ãžã®çœ²å ã§åãäžããŸãã) ãäœãå Žåã¯ãGPG 眲åçšã®éµãç»é²ããŠãããšäŸ¿å©ã§ãã éµã® ID ãèšå®ããã«ã¯ããã®ããã«ããŸãã
$ git config --global user.signingkey <gpg-key-id>
ããã§ãgit tag
ã³ãã³ãã§ãã¡ãã¡éµãæå®ããªããŠãã¿ã°ã«çœ²åã§ããããã«ãªããŸããã
$ git tag -s <tag-name>
core.excludesfile
ãããžã§ã¯ãããšã® .gitignore
ãã¡ã€ã«ã§ãã¿ãŒã³ãæå®ãããšãgit add
ãããšãã« Git ããã®ãã¡ã€ã«ãç¡èŠããŠã¹ããŒãžããªãããã«ãªããŸããããã«ã€ããŠã¯ ãã¡ã€ã«ã®ç¡èŠ ã§èª¬æããŸããã
ã§ãããäœæ¥äžã®ãã¹ãŠã®ãªããžããªã§ãããç¹å®ã®ãã¡ã€ã«ãç¡èŠãããå ŽåããããŸãã
Mac OS X ã䜿ã£ãŠããã®ãªãã .DS_Store
ãšãããã¡ã€ã«ã«èŠããŒããããã§ãããã
䜿ã£ãŠãããšãã£ã¿ã Emacs ã Vim ãªãã ~
ã§çµãããã¡ã€ã«ã®ããšãç¥ã£ãŠããããšãšæããŸãã
ãã®ãããªèšå®ãè¡ãã«ã¯ãã°ããŒãã«ãª .gitignore
ã®ãããªãã¡ã€ã«ãå¿
èŠã§ãã
~/.gitignore_global
ãã¡ã€ã«ãžæ¬¡ã®å
容ãæžã蟌ãã§ã
*~
.DS_Store
ãã®äžã§ git config --global core.excludesfile ~/.gitignore_global
ãå®è¡ããã°ããããã®ãã¡ã€ã«ã§æãç
©ããããšã¯äºåºŠãšãªããªããŸãã
help.autocorrect
Git ã§ã³ãã³ããæã¡ééãããšããããªãµãã«è¡šç€ºãããŸãã
$ git chekcout master
git: 'chekcout' is not a git command. See 'git --help'.
Did you mean this?
checkout
Git ã¯æ°ãå©ãããŠãäœããããã£ãã®ãæšæž¬ã¯ããŠãããŸãããå®è¡ãŸã§ã¯ããŸããã
help.autocorrect
ã 1 ã«ããŠãããšã Git ã¯å®éã«ãã®ã³ãã³ããå®è¡ããããšããŸãã
$ git chekcout master
WARNING: You called a Git command named 'chekcout', which does not exist.
Continuing under the assumption that you meant 'checkout'
in 0.1 seconds automatically...
â0.1 secondsâ ãšããç®æã«æ³šç®ããŠãã ããã help.autocorrect
ã¯æŽæ°å€ã§ã0.1ç§åäœã§ã®æéãè¡šããŠããŸãã
ãã®ããã仮㫠50 ãèšå®ãããªããèªåä¿®æ£ããã³ãã³ããå®è¡ãããåã« 5 ç§ã®ç¶äºãäžããããŸãã
Git ã«ãããè²
Git ã§ã¯ãã¿ãŒããã«ãžã®åºåã«è²ãã€ããããšãã§ããŸããã±ã£ãšèŠãŠããã°ãããæ軜ã«åºåå 容ãææ¡ã§ããããã«ãªãã§ãããã ããŸããŸãªãªãã·ã§ã³ã§ãã奜ã¿ã«åãããŠè²ãèšå®ããŸãããã
color.ui
Git ã¯èªåçã«å€§åã®åºåã«è²ã¥ããããŸããã§ããããã®æåãæ°ã«å ¥ããªããªãããã®ããã®ãã¹ã¿ãŒã¹ã€ããããããŸãã ã¿ãŒããã«ãžã®åºåãžã®è²ä»ãããã¹ãŠãªãã«ãããªãã以äžã®ããã«ããŸãã
$ git config --global color.ui false
ããã©ã«ãã®èšå®ã¯ auto
ã§ãçŽæ¥ã¿ãŒããã«ãžåºåããå Žåã«ã¯è²ä»ããè¡ããŸããããã€ãããã¡ã€ã«ãžãªãã€ã¬ã¯ãããå Žåã«ã¯ã«ã©ãŒã³ã³ãããŒã«ã³ãŒããåºåããŸããã
ãŸã always
ãæå®ãããšãã¿ãŒããã«ã§ãã£ãŠããã€ãã§ãã£ãŠãè²ãã€ããŸãã
always
ã䜿ãããšã¯ããŸããªãã§ãããããããŠãã®å Žåã¯ãã«ã©ãŒã³ãŒããå«ãçµæããªãã€ã¬ã¯ãããããã°ã Git ã³ãã³ãã« --color
ãã©ã°ãæž¡ãã°ã«ã©ãŒã³ãŒãã®äœ¿çšã匷å¶ã§ããŸãã
ãµã ãã¯ããã©ã«ãã®èšå®ã§èŠæãæºãããã§ãããã
color.*
ã©ã®ã³ãã³ããã©ã®ããã«è²ã¥ããããããã现ããã«æå®ãããå Žåãã³ãã³ãåäœã®è²ã¥ãèšå®ã䜿çšããŸãã
ãããã®é
ç®ã«ã¯ true
ã false
ããã㯠always
ãæå®ã§ããŸãã
color.branch color.diff color.interactive color.status
ããã«ããããã®é ç®ã§ã¯ãµãèšå®ã䜿ããåºåã®äžéšã«ã€ããŠç¹å®ã®è²ã䜿ãããã«æå®ããããšãã§ããŸãã ããšãã°ãdiff ã®åºåã§ãã¡ã¿æ å ±ãé»å°ã«éã®å€ªåã§åºåããããå Žåã¯æ¬¡ã®ããã«ããŸãã
$ git config --global color.diff.meta "blue black bold"
è²ãšããŠæå®ã§ããå€ã¯ normal
ã black
ã redã `green
ã yellow
ã blue
ã magenta
ã cyan
ã white
ã®ããããã§ããå
ã»ã©ã®äŸã® bold ã®ããã«å±æ§ãæå®ã§ããŸããbold
ã dim
ã ul
ïŒäžç·ã€ãïŒã blink
ã reverse
ïŒæåãšèæ¯ã®è²ãéã«ããïŒã®ãããããæå®ã§ããŸãã
å€éšã®ããŒãžããŒã«ããã³ diff ããŒã«
Git ã«ã¯ãå éšç㪠diff ã®å®è£ ãçµã¿èŸŒãŸããŠããŸããæ¬æžã§ãããŸã§èŠãŠããå 容ã¯ãããã䜿çšããŠããŸããã§ãããå€éšã®ããŒã«ã䜿ãããèšå®ããããšãã§ããŸãã ãŸããã³ã³ããªã¯ããæåã§è§£æ±ºããã®ã§ã¯ãªãã°ã©ãã£ã«ã«ãªã³ã³ããªã¯ã解æ¶ããŒã«ã䜿ãããèšå®ããããšãã§ããŸãã ããã§ã¯ Perforce Visual Merge Tool (P4Merge) ã䜿ã£ãŠ diff ã®è¡šç€ºãšããŒãžã®åŠçãè¡ããããã«ããäŸã瀺ããŸããããã¯ãã°ãããã°ã©ãã£ã«ã«ããŒã«ã§ããããç¡æã§äœ¿ããããã§ãã
P4Merge ã¯ãã¹ãŠã®äž»èŠãã©ãããã©ãŒã äžã§åäœããã®ã§ãå®éã«è©ŠããŠã¿ãã人ã¯è©ŠããŠã¿ããšããã§ãããã
ãã®äŸã§ã¯ãMac ã Linux 圢åŒã®ãã¹åãäŸã«äœ¿ããŸããWindows ã®å Žåã¯ã/usr/local/bin
ã®ãšãããç°å¢ã«åããããã¹ã«çœ®ãæããŠãã ããã
ãŸããP4Merge ã ããããŠã³ããŒãããŸãã
次ã«ãã³ãã³ããå®è¡ããããã®å€éšã©ãããŒã¹ã¯ãªãããçšæããŸãã
ãã®äŸã§ã¯ãMac çšã®å®è¡ãã¹ã䜿ããŸããä»ã®ã·ã¹ãã ã§äœ¿ãå Žåã¯ãp4merge
ã®ãã€ããªãã€ã³ã¹ããŒã«ãããå Žæã«çœ®ãæããŠãã ããã
次ã®ãããªå
容ã®ããŒãžçšã©ãããŒã¹ã¯ãªãã extMerge
ãçšæããŠãã ãããããã¯ã p4merge
ã«ãã¹ãŠã®åŒæ°ãæž¡ããŠåŒã³åºããŸãã
$ cat /usr/local/bin/extMerge
#!/bin/sh
/Applications/p4merge.app/Contents/MacOS/p4merge $*
diff ã®ã©ãããŒã¯ã7 ã€ã®åŒæ°ãæž¡ãããŠããããšã確èªããããã§ãã®ãã¡ã®ãµãã€ãããŒãžã¹ã¯ãªããã«æž¡ããŸãã ããã©ã«ãã§ã¯ãGit ã¯æ¬¡ã®ãããªåŒæ°ã diff ããã°ã©ã ã«æž¡ããŸãã
path old-file old-hex old-mode new-file new-hex new-mode
ããã§å¿
èŠãªåŒæ°ã¯ old-file
ãš new-file
ã ããªã®ã§ãã©ãããŒã¹ã¯ãªããã§ã¯ããããæž¡ãããã«ããŸãã
$ cat /usr/local/bin/extDiff
#!/bin/sh
[ $# -eq 7 ] && /usr/local/bin/extMerge "$2" "$5"
ãŸãããããã®ããŒã«ã¯å®è¡å¯èœã«ããŠãããªããã°ãªããŸããã
$ sudo chmod +x /usr/local/bin/extMerge
$ sudo chmod +x /usr/local/bin/extDiff
ããã§ãèªåã®ããŒãžããŒã«ã diff ããŒã«ã䜿ããããã«èšå®ããæºåãæŽããŸããã
èšå®é
ç®ã¯ã²ãšã€ã ãã§ã¯ãããŸããããŸã merge.tool
ã§ã©ããªããŒã«ã䜿ãã®ãã Git ã«äŒãã mergetool.<tool>.cmd
ã§ãã®ã³ãã³ããå®è¡ããæ¹æ³ãæå®ããmergetool.<tool>.trustExitCode
ã§ã¯ããã®ã³ãã³ãã®çµäºã³ãŒãã§ããŒãžãæåãããã©ãããå€æã§ããã®ãããæå®ããdiff.external
ã§ã¯ diff ã®éã«å®è¡ããã³ãã³ããæå®ããŸããã€ãŸãããã®ãã㪠4 ã€ã®ã³ãã³ããå®è¡ããããšã«ãªããŸãã
$ git config --global merge.tool extMerge
$ git config --global mergetool.extMerge.cmd \
'extMerge \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"'
$ git config --global mergetool.extMerge.trustExitCode false
$ git config --global diff.external extDiff
ãããã¯ã~/.gitconfig
ãã¡ã€ã«ãç·šéããŠãã®ãããªè¡ãè¿œå ããŸãã
[merge]
tool = extMerge
[mergetool "extMerge"]
cmd = extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
trustExitCode = false
[diff]
external = extDiff
ãã¹ãŠèšå®ãçµãããããã®ãã㪠diff ã³ãã³ããå®è¡ãããšã
$ git diff 32d1776b1^ 32d1776b1
çµæãã³ãã³ãã©ã€ã³ã«åºåãããããã«ãGit ãã P4Merge ãåŒã³åºããã次ã®ããã«ãªããŸãã
ãµãã€ã®ãã©ã³ããããŒãžããŠã³ã³ããªã¯ããçºçããå Žå㯠git mergetool
ãå®è¡ããŸãããããš P4Merge ãç«ã¡äžãããã³ã³ããªã¯ãã®è§£æ±ºã GUI ããŒã«ã§è¡ããããã«ãªããŸãã
ãã®ãããªã©ãããŒãèšå®ããŠãããšãããšã§ diff ããŒã«ãããŒãžããŒã«ãç°¡åã«å€æŽã§ããŸãã
ããšãã° extDiff
ã extMerge
㧠KDiff3 ãå®è¡ãããããã«å€æŽããã«ã¯ extMerge
ãã¡ã€ã«ããã®ããã«å€æŽããã ãã§ããã®ã§ãã
$ cat /usr/local/bin/extMerge
#!/bin/sh
/Applications/kdiff3.app/Contents/MacOS/kdiff3 $*
ããã§ãGit ã§ã® diff ã®é²èŠ§ãã³ã³ããªã¯ãã®è§£æ±ºã®éã« KDiff3 ãç«ã¡äžããããã«ãªããŸããã
Git ã«ã¯ããŸããŸãªããŒãžããŒã«çšã®èšå®ãäºåã«æºåãããŠãããç¹ã«èšå®ããªããŠãå©çšã§ããŸãã ãµããŒããããŠããããŒã«ã確èªããã«ã¯ã次ã®ã³ãã³ããå®è¡ããŸãã
$ git mergetool --tool-help
'git mergetool --tool=<tool>' may be set to one of the following:
emerge
gvimdiff
gvimdiff2
opendiff
p4merge
vimdiff
vimdiff2
The following tools are valid, but not currently available:
araxis
bc3
codecompare
deltawalker
diffmerge
diffuse
ecmerge
kdiff3
meld
tkdiff
tortoisemerge
xxdiff
Some of the tools listed above only work in a windowed
environment. If run in a terminal-only session, they will fail.
KDiff3 ã diff ããŒã«ãšããŠã§ã¯ãªãããŒãžã®ãšãã«ã ã䜿ãããå Žåã¯ãkdiff3 ã³ãã³ãã«ãã¹ãéã£ãŠããç¶æ ã§æ¬¡ã®ã³ãã³ããå®è¡ããŸãã
$ git config --global merge.tool kdiff3
extMerge
ã extDiff
ãæºåããã«ãã®ã³ãã³ããå®è¡ãããšãããŒãžã®è§£æ±ºã®éã«ã¯ KDiff3 ãç«ã¡äžã㊠diff ã®éã«ã¯éåžžã® Git ã® diff ããŒã«ã䜿ãããã«ãªããŸãã
æžåŒèšå®ãšç©ºçœæå
æžåŒèšå®ã空çœæåã®åé¡ã¯åŸ®åŠã«ãã£ãšããããã®ã§ããšãã«ããŸããŸãªãã©ãããã©ãŒã ã§éçºããŠãã人ãã¡ãšå ±åäœæ¥ããããšãã«åé¡ã«ãªããã¡ã§ãã 䜿ã£ãŠãããšãã£ã¿ãç¥ãã¬éã«ç©ºçœæåãåã蟌ãã§ããŸã£ãŠããã Windows ã§éçºããŠãã人ãè¡æ«ã«ãã£ãªããžãªã¿ãŒã³ãä»ãå ããŠããŸã£ãããªã©ããŠããããé¢åãªç¶æ ã«ãªã£ãŠããŸãããšãå€ã ãããŸãã Git ã§ã¯ããããã£ãåé¡ã«å¯ŸåŠããããã®èšå®é ç®ãçšæããŠããŸãã
core.autocrlf
èªåã Windows ã§éçºããŠããäžæ¹ãããŒã ã®äžã« Windows 以å€ã®ç°å¢ã§éçºããŠãã人ãããå ŽåïŒéãåæ§ïŒã«ã¯ãæ¹è¡ã³ãŒãã®åé¡ã«å·»ã蟌ãŸããããšããããã¡ã§ãã Windows ã§ã¯ãã£ãªããžãªã¿ãŒã³ãšã©ã€ã³ãã£ãŒãã§ãã¡ã€ã«ã®æ¹è¡ãè¡šãã®ã§ãããMac ã Linux ã§ã¯ã©ã€ã³ãã£ãŒãã ãã§æ¹è¡ãè¡šããšããéããåå ã§ãã ããã¯ããããªéãã§ã¯ãããŸãããããŸããŸãªãã©ãããã©ãŒã ã«ãŸãããäœæ¥ã§ã¯éåžžã«é¢åãªãã®ã§ããWindows ã®ãšãã£ã¿ã«ã¯ãLFã ãã®æ¹è¡ãã ãŸã£ãŠCRLFã«çœ®ãæãããããŠãŒã¶ãEnterããŒãæŒäžããéã«CRãšLFã®äž¡æ¹ãæ¿å ¥ããããããã®ãæ°å€ããããŸãã
Git ã¯ãã®åé¡ã«å¯ŸåŠããããã«ãã³ãããããéã«ã¯è¡æ«ã® CRLF ã LF ã«èªåå€æãããã¡ã€ã«ã·ã¹ãã äžã«ãã§ãã¯ã¢ãŠããããšãã«ã¯éã®å€æãè¡ãããã«ã§ããŸãã
ãã®æ©èœã䜿ãã«ã¯ core.autocrlf
ãèšå®ããŸãã
Windows ã§äœæ¥ããããšãã«ããã true
ã«èšå®ãããšãã³ãŒãããã§ãã¯ã¢ãŠããããšãã«è¡æ«ã® LF ã CRLF ã«èªåå€æããŠãããŸãã
$ git config --global core.autocrlf true
Linux ã Mac ãªã©ã®è¡æ«ã« LF ã䜿ãã·ã¹ãã ã§äœæ¥ãããŠããå Žåã¯ãGit ã«ãã§ãã¯ã¢ãŠãæã®èªåå€æããããŠããŸããšå°ããŸããããããè¡æ«ã CRLF ãªãã¡ã€ã«ãçŽã蟌ãã§ããŸã£ãå Žåã«ã¯ Git ã«èªåä¿®æ£ããŠããããããã®ã§ãã
ã³ãããæã® CRLF ãã LF ãžã®å€æã¯ããããããã©ããã以å€ã®èªåå€æãäžèŠãªå Žåã¯ãcore.autocrlf
ã input ã«èšå®ããŸãã
$ git config --global core.autocrlf input
ãã®èšå®ã¯ãWindows ã«ãã§ãã¯ã¢ãŠããããšãã® CRLF ãžã®å€æã¯è¡ããŸãããMac ã Linux ãžã®ãã§ãã¯ã¢ãŠãæ㯠LF ã®ãŸãŸã«ããŸãã
Windows ã®ã¿ã®ãããžã§ã¯ãã§äœæ¥ãããŠããã®ãªãããã®æ©èœãç¡å¹ã«ããŠãã£ãªããžãªã¿ãŒã³ããã®ãŸãŸãªããžããªã«èšé²ããŠãããã§ãããããã®å Žåã¯ãå€ false
ãèšå®ããŸãã
$ git config --global core.autocrlf false
core.whitespace
Git ã«ã¯ã空çœæåã«é¢ããåé¡ãèŠã€ããŠä¿®æ£ããããã®èšå®ããããŸãã 空çœæåã«é¢ããäž»èŠãªå ã€ã®åé¡ã«å¯Ÿå¿ãããã®ã§ããã®ãã¡äžã€ã¯ããã©ã«ãã§æå¹ã«ãªã£ãŠããŸããæ®ãã®äžã€ã¯ããã©ã«ãã§ã¯æå¹ã«ãªã£ãŠããŸããããæå¹åããããšãã§ããŸãã
ããã©ã«ãã§æå¹ã«ãªã£ãŠããèšå®ã¯ãè¡æ«ã®ç©ºçœæåãèŠã€ãã blank-at-eol
ããã¡ã€ã«æ«å°Ÿã®ç©ºçœæåãèŠã€ãã blank-at-eof
ãè¡é ã®ã¿ãæåããåã«ãã空çœæåãèŠã€ãã space-before-tab
ã§ãã
ããã©ã«ãã§ã¯ç¡å¹ã ããã©ãæå¹ã«ããããšãã§ããäžã€ã®èšå®ã¯ãè¡é ãã¿ãæåã§ãªã空çœæåã«ãªã£ãŠããè¡ãèŠã€ãã indent-with-non-tab
ïŒç©ºçœæåã®æ°ã¯ tabwidth
ãªãã·ã§ã³ã§å¶åŸ¡å¯èœïŒãè¡å
ã®ã€ã³ãã³ãéšåã«ããã¿ãæåãèŠã€ãã tab-in-indent
ãè¡æ«ã®ãã£ãªããžãªã¿ãŒã³ã蚱容ãã cr-at-eol
ã§ãã
ãããã®ãªã³ã»ãªããåãæ¿ããã«ã¯ãcore.whitespace
ã«ã«ã³ãåºåãã§é
ç®ãæå®ããŸãã
ç¡å¹ã«ãããå Žåã¯ãèšå®æååã§ãã®é
ç®ãçç¥ãããããããã¯é
ç®åã®åã« -
ãã€ããŸãã
ããšãã° cr-at-eol
以å€ã®ãã¹ãŠãèšå®ãããå Žåã¯ããã®ããã«ããŸãã
$ git config --global core.whitespace \
trailing-space,space-before-tab,indent-with-non-tab
git diff
ã³ãã³ããå®è¡ãããšãã« Git ããããã®åé¡ãæ€åºãããšããã®éšåãè²ä»ãããŠè¡šç€ºããŸããä¿®æ£ããŠããã³ãããããããã«ããŸãããã
ãã®èšå®ã¯ãgit apply
ã§ããããé©çšããéã«ãå©ããšãªããŸãã
空çœã«é¢ããåé¡ãå«ãããããé©çšãããšãã«èŠåãçºããŠã»ããå Žåã«ã¯ã次ã®ããã«ããŸãã
$ git apply --whitespace=warn <patch>
ãããã¯ãåé¡ãèªåçã«ä¿®æ£ããŠããããããé©çšãããå Žåã¯ã次ã®ããã«ããŸãã
$ git apply --whitespace=fix <patch>
ãããã®èšå®ã¯ãgit rebase
ã³ãã³ãã«ãé©çšãããŸãã
空çœã«é¢ããåé¡ãå«ãã³ããããããããã©ãŸã ãããå
¬éãªããžããªã«ããã·ã¥ããŠããªãå Žåã¯ã git rebase --whitespace=fix
ãå®è¡ããã°ãããããæžãæããŠç©ºçœåé¡ãèªåä¿®æ£ããŠãããŸãã
ãµãŒããŒã®èšå®
Git ã®ãµãŒããŒåŽã®èšå®ãªãã·ã§ã³ã¯ããã»ã©å€ããããŸããããããã€ãèå³æ·±ããã®ãããã®ã§çŽ¹ä»ããŸãã
receive.fsckObjects
ããã©ã«ãã§ã¯ãGit ã¯ããã·ã¥ã§åãåã£ããªããžã§ã¯ãã® SHA-1 ãã§ãã¯ãµã ãäžèŽããŠããŠæå¹ãªãªããžã§ã¯ããæããŠãããšããããšããã§ãã¯ãããããšãã§ããŸãã
ã§ãããããã©ã«ãã§ã¯ãã®ãã§ãã¯ã¯è¡ããªãããã«ãªã£ãŠããŸãããã®ãã§ãã¯ã¯æ¯èŒçéããåŠçã§ããããªããžããªã®ãµã€ãºã倧ããã£ããããã·ã¥ããéãå€ãã£ãããããšãæ¯åãã§ãã¯ãããã®ã«ã¯æéããããã§ãããã
æ¯åã®ããã·ã¥ã®éã« Git ã«ãªããžã§ã¯ãã®äžè²«æ§ããã§ãã¯ããããå Žåã¯ãreceive.fsckObjects
ã true ã«ããŠåŒ·å¶çã«ãã§ãã¯ãããããã«ããŸãã
$ git config --system receive.fsckObjects true
ããã§ãGit ããªããžããªã®æŽåæ§ã確èªããŠããã§ãªããšããã·ã¥ãèªããããªãããã«ãªããŸããå£ããããŒã¿ããŸã¡ãã£ãŠåãå ¥ããŠããŸãããšããªããªããŸããã
receive.denyNonFastForwards
ãã§ã«ããã·ã¥ããã³ãããããªããŒã¹ããŠããäžåºŠããã·ã¥ããå Žåããããã¯ãªã¢ãŒããã©ã³ããçŸåšæããŠããã³ããããå«ãŸãªãã³ããããããã·ã¥ããããšããå Žåã¯ãããã·ã¥ãæåŠãããŸãã
ããã¯æªããªãæ¹éã§ããããããããªããŒã¹ã®å Žåã¯ãèªåãäœãããŠããã®ãããã¡ããšææ¡ããŠããã°ãããã·ã¥ã®éã« -f
ãã©ã°ãæå®ããŠåŒ·å¶çã«ãªã¢ãŒããã©ã³ããæŽæ°ããããšãã§ããŸãã
ãã®ãããªåŒ·å¶æŽæ°æ©èœãç¡å¹ã«ããã«ã¯ãreceive.denyNonFastForwards
ãèšå®ããŸãã
$ git config --system receive.denyNonFastForwards true
ããã²ãšã€ã®æ¹æ³ãšããŠããµãŒããŒåŽã® receive ããã¯ã䜿ãããšãã§ããŸãããã¡ãã®æ¹æ³ã«ã€ããŠã¯åŸã»ã©ç°¡åã«èª¬æããŸãã receive ããã¯ã䜿ãã°ãç¹å®ã®ãŠãŒã¶ãŒã ã匷å¶æŽæ°ãç¡å¹ã«ãããªã©ãã现ãããªå¶åŸ¡ãã§ããããã«ãªããŸãã
receive.denyDeletes
denyNonFastForwards
ã®å¶éãåé¿ããæ¹æ³ãšããŠããã£ãããã©ã³ããåé€ããŠããæ°ããã³ããããåç
§ãããã©ã³ããããã·ã¥ããªããããšãã§ããŸãã
ãããç¡å¹ã«ããã«ã¯ã receive.denyDeletes
ã true ã«èšå®ããŸãã
$ git config --system receive.denyDeletes true
ããã¯ãããã·ã¥ã«ãããã©ã³ããã¿ã°ã®åé€ãäžåæåŠãã誰ãåé€ã§ããªãããã«ããŸãã ãªã¢ãŒããã©ã³ããåé€ããã«ã¯ããµãŒããŒäžã® ref ãã¡ã€ã«ãæã§åé€ããªããã°ãªããŸãããACL ã䜿ã£ãŠããŠãŒã¶ãŒåäœã§ãããå¶éããããšãã§ããŸããããã®æ¹æ³ã¯ Git ããªã·ãŒã®å®æœäŸ ã§æ±ããŸãã