-
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.2 Git ã®ã«ã¹ã¿ãã€ãº - Git ã®å±æ§
Git ã®å±æ§
èšå®é
ç®ã®äžã«ã¯ããã¹ã«å¯ŸããŠæå®ã§ãããã®ããããŸããGit ã¯ãããã®èšå®ããæå®ãããã¹ã®ãµããã£ã¬ã¯ããªããã¡ã€ã«ã«ã®ã¿é©çšããŸãã
ããããã¹åºæã®èšå®ã¯ã Git ã®å±æ§ãšåŒã°ãããããã£ã¬ã¯ã㪠ïŒéåžžã¯ãããžã§ã¯ãã®ã«ãŒããã£ã¬ã¯ããªïŒã®çŽäžã® .gitattributes
ãããããã¯ãã®ãã¡ã€ã«ããããžã§ã¯ããšãšãã«ã³ãããããããªãå Žå㯠.git/info/attributes
ã«èšå®ããŸãã
å±æ§ã䜿ããšããã¡ã€ã«ããã£ã¬ã¯ããªåäœã§åå¥ã®ããŒãžæŠç¥ãæå®ããããããã¹ããã¡ã€ã«ä»¥å€ã® diff ãåãæ¹æ³ãæ瀺ãããããããã¯ãã§ãã¯ã€ã³ããã§ãã¯ã¢ãŠãã®åã«ãã®å 容ã Git ã«ãã£ã«ã¿ãªã³ã°ããããã§ããŸãã ãã®ã»ã¯ã·ã§ã³ã§ã¯ãGit ãããžã§ã¯ãã§ãã¹ã«å¯ŸããŠèšå®ã§ããå±æ§ã®ããã€ãã«ã€ããŠåŠã³ãå®éã«ãã®æ©èœã䜿ãäŸãèŠãŠãããŸãã
ãã€ããªãã¡ã€ã«
Git ã®å±æ§ã䜿ã£ãŠã§ããã¡ãã£ãšããæãšããŠãã©ã®ãã¡ã€ã«ããã€ããªãã¡ã€ã«ãªã®ãã (ãã®ä»ã®æ¹æ³ã§å€å¥ã§ããªãå Žåã®ããã«) æå®ããäžã§ã Git ã«å¯ŸããŠãã€ããªãã¡ã€ã«ã®æ±ãæ¹ãæ瀺ãããšãããã®ããããŸãã ããšãã°ãæ©æ¢°ã§çæããããã¹ããã¡ã€ã«ã®äžã«ã¯ diff ãååŸã§ããªããã®ããããŸããããã€ããªãã¡ã€ã«ã§ãã£ãŠã diff ãååŸã§ãããã®ããããŸãã ããã Git ã«æ瀺ããæ¹æ³ã玹ä»ããŸãã
ãã€ããªãã¡ã€ã«ã®ç¹å®
ããã¹ããã¡ã€ã«ã®ããã«èŠãããã¡ã€ã«ã§ãã£ãŠããäœããã®ç®çã®ããã«æå³çã«ãã€ããªããŒã¿ãšããŠæ±ãããããšããããŸãã
ããšãã°ãMac ã® Xcode ãããžã§ã¯ãã®äžã«ã¯ .pbxproj
ã§çµããååã®ãã¡ã€ã«ããããŸãããã㯠JSON (ãã¬ãŒã³ããã¹ã圢åŒã® JavaScript ã®ããŒã¿ãã©ãŒããã) ã®ããŒã¿ã»ããã§ãIDE ããã«ãã®èšå®ãªã©ããã£ã¹ã¯ã«æžãåºãããã®ã§ãã
ãã®ãã¡ã€ã«ã®å
容ã¯ãã¹ãŠ UTF-8 ã®æåãªã®ã§ãçè«äžã¯ããã¹ããã¡ã€ã«ã§ãããšèšããŸãããããããã®ãã¡ã€ã«ãããã¹ããã¡ã€ã«ãšããŠæ±ãããã¯ãããŸãããå®éã®ãšããããã®ãã¡ã€ã«ã¯è»œéãªããŒã¿ããŒã¹ãšããŠäœ¿ãããŠããããã§ããä»ã®äººãå€æŽããå
容ã¯ããŒãžã§ããŸããããdiff ããšã£ãŠãããŸãæå³ããããŸããã
ãã®ãã¡ã€ã«ã¯ãåºæ¬çã«æ©æ¢°ãåŠçãããã®ãªã®ã§ãã
èŠããã«ããã€ããªãã¡ã€ã«ãšåãããã«æ±ããããšããããšã§ãã
ãã¹ãŠã® pbxproj
ãã¡ã€ã«ããã€ããªããŒã¿ãšããŠæ±ããã Git ã«æå®ããã«ã¯ã次ã®è¡ã .gitattributes
ãã¡ã€ã«ã«è¿œå ããŸãã
*.pbxproj binary
ããã§ãGit ã CRLF åé¡ã®å¯Ÿå¿ãããããšããªããªããŸãããgit show
ã git diff
ãå®è¡ãããšãã«ããã®ãã¡ã€ã«ã® diff ã調ã¹ãããšã¯ãªããªããŸãã
ãã€ããªãã¡ã€ã«ã®å·®å
ãã€ããªãã¡ã€ã«ã«å¯ŸããŠæå³ã®ããå·®åãåãéã«ããGit ã®å±æ§ã䜿ãããšãã§ããŸãã æ®éã® diff ã§ãæ¯èŒã§ããããããã€ããªããŒã¿ãããã¹ãããŒã¿ã«å€æããæ¹æ³ãGitã«æããã°ããã®ã§ãã
ãã®ãã¯ããã¯ã䜿ã£ãŠãŸã解決ãããããšãšããã°ã人é¡ã«ãšã£ãŠæãåä»ãªåé¡ã®ã²ãšã€ãWordã§äœæããææžã®ããŒãžã§ã³ç®¡çã§ã¯ãªãã§ããããã
å¥åŠãªããšã«ãWordã¯ææªã®ãšãã£ã¿ã ãšå
šãŠã®äººãç¥ã£ãŠããã«ãä¿ããããçãWordã䜿ã£ãŠããŸãã
WordææžãããŒãžã§ã³ç®¡çããããšæã£ããªããGitã®ãªããžããªã«ããããè¿œå ããŠããŸãšããŠã³ãããããã°ããã®ã§ããããããããã§ããã®ã§ããããïŒ
ããªãã git diff
ããã€ãéãã«å®è¡ãããšã次ã®ããã«è¡šç€ºãããã ãã§ãã
$ git diff
diff --git a/chapter1.docx b/chapter1.docx
index 88839c4..4afcb7c 100644
Binary files a/chapter1.docx and b/chapter1.docx differ
ããã§ã¯ã2ã€ã®ããŒãžã§ã³ããã§ãã¯ã¢ãŠãããŠãç®èŠã§èŠæ¯ã¹ãªããŠã¯ãæ¯èŒã¯ã§ããŸããããïŒ Gitã®å±æ§ã䜿ãã°ããããããŸã解決ã§ããŸãã `.gitattributes`ã«æ¬¡ã®è¡ãè¿œå ããŠäžããã
*.docx diff=word
ããã¯ãæå®ãããã¿ãŒã³ (.docx
) ã«ãããããå
šãŠã®ãã¡ã€ã«ã«å¯ŸããŠãå·®åã衚瀺ããæã«ã¯ âwordâ ãšãããã£ã«ã¿ã䜿ããã Git ã«æ瀺ããŠããã®ã§ãã
ã§ã¯ã âwordâ ãã£ã«ã¿ãšã¯äœã§ããããïŒ
ããã¯èªåã§çšæããªããã°ãªããŸããã
ããã§ã¯ã docx2txt
ã䜿ã£ãŠWordææžãããã¹ããã¡ã€ã«ã«å€æããäžã§ãæ£ãã diff ãåããããã«èšå®ããŠã¿ãŸãããã
ãŸãã docx2txt
ãã€ã³ã¹ããŒã«ããå¿
èŠããããŸãã http://docx2txt.sourceforge.net ããããŠã³ããŒããããã INSTALL
ãã¡ã€ã«ã®æ瀺ã«åŸã£ãŠãã·ã§ã«ããèŠããå Žæã«ãã¡ã€ã«ã眮ããŠãã ããã
次ã«ãåºåã Git ã«åãããŠå€æããã©ãããŒã¹ã¯ãªãããäœæããŸãã
ãã¹ã®éã£ãå Žæã«ã `docx2txt`ãšããååã®ãã¡ã€ã«ã次ã®å
容ã§äœæããŠãã ããã
#!/bin/bash
docx2txt.pl $1 -
äœã£ããã¡ã€ã«ã« chmod a+x
ããã®ãå¿ããªãã§ãã ããã
æåŸã«ãGit ããã®ãã¡ã€ã«ã䜿ãããã«èšå®ããŸãã
$ git config diff.word.textconv docx2txt
ããã§ãäºã€ã®ã¹ãããã·ã§ããã® diff ãåãéã«ããã¡ã€ã«åã®æ«å°Ÿã .docx
ã ã£ããã âwordâ ãã£ã«ã¿ãéãïŒãã® âwordâ ãã£ã«ã¿ã¯ docx2txt
ãšããããã°ã©ã ãšããŠå®çŸ©ãããŠããïŒãšããããšã Git ã«äŒãããŸããã
ããããããšã§ãWordãã¡ã€ã«ã®å·®åãåãéã«ãããå¹æçãªããã¹ãããŒã¹ã§ã®å·®åãåãããšãã§ããããã«ãªããŸãã
äŸã瀺ããŸãããããã®æ¬ã®ç¬¬1ç« ãWord圢åŒã«å€æããGitãªããžããªã«ç»é²ããŸããã
ããã«ãæ°ãã段èœãè¿œå ããŸããã
git diff
ã®åºåã¯æ¬¡ã®ããã«ãªããŸãã
$ git diff
diff --git a/chapter1.docx b/chapter1.docx
index 0b013ca..ba25db5 100644
--- a/chapter1.docx
+++ b/chapter1.docx
@@ -2,6 +2,7 @@
This chapter will be about getting started with Git. We will begin at the beginning by explaining some background on version control tools, then move on to how to get Git running on your system and finally how to get it setup to start working with. At the end of this chapter you should understand why Git is around, why you should use it and you should be all setup to do so.
1.1. About Version Control
What is "version control", and why should you care? Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. For the examples in this book you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.
+Testing: 1, 2, 3.
If you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use. It allows you to revert files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Using a VCS also generally means that if you screw things up or lose files, you can easily recover. In addition, you get all this for very little overhead.
1.1.1. Local Version Control Systems
Many people's version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they're clever). This approach is very common because it is so simple, but it is also incredibly error prone. It is easy to forget which directory you're in and accidentally write to the wrong file or copy over files you don't mean to.
Gitã¯ãè¿œå ãã âTesting: 1, 2, 3.â ãšããæ£ããæååãéŠå°Ÿããããã€ãç°¡æœã«ç¥ãããŠãããŸããã ããã ãã§ã¯å®ç§ã§ã¯ãããŸããïŒæžåŒã®å€æŽã¯ããã§ã¯è¡šç€ºãããŠããŸããïŒãã確å®ã«åäœããŠããŸãã
ãã®ä»ã®èå³æ·±ãåé¡ãšããŠã¯ãç»åãã¡ã€ã«ã®å·®åããããŸãã
ã²ãšã€ã®æ¹æ³ãšããŠãEXIFæ
å ±ïŒå€ãã®ãã¡ã€ã«åœ¢åŒã§äœ¿çšãããŠããã¡ã¿ããŒã¿ïŒãæœåºãããã£ã«ã¿ã䜿ãæ¹æ³ããããŸãã
exiftool`ãããŠã³ããŒãããŠã€ã³ã¹ããŒã«ããã°ãç»åããŒã¿ããã¡ã¿ããŒã¿ãè¡šãããã¹ãããŒã¿ãžå€æã§ããŸããããã«ãã£ãŠã diff ã§ã¯å°ãªããšããå€æŽå
容ãããã¹ã圢åŒã§è¡šç€ºã§ããããã«ãªããŸãã
ã§ã¯ããã§ã以äžã®è¡ã
.gitattributes`ã«è¿œå ããŠã¿ãŸãããã
*.png diff=exif
ç¶ããŠãããã»ã©ã€ã³ã¹ããŒã«ããããŒã«ã䜿ãããGitã®èšå®ãå€æŽããŸãã
$ git config diff.exif.textconv exiftool
ãããžã§ã¯ãäžã®ç»åããŒã¿ã眮ãæã㊠git diff
ãå®è¡ãããšã次ã®ããã«è¡šç€ºãããã§ãããã
diff --git a/image.png b/image.png
index 88839c4..4afcb7c 100644
--- a/image.png
+++ b/image.png
@@ -1,12 +1,12 @@
ExifTool Version Number : 7.74
-File Size : 70 kB
-File Modification Date/Time : 2009:04:21 07:02:45-07:00
+File Size : 94 kB
+File Modification Date/Time : 2009:04:21 07:02:43-07:00
File Type : PNG
MIME Type : image/png
-Image Width : 1058
-Image Height : 889
+Image Width : 1056
+Image Height : 827
Bit Depth : 8
Color Type : RGB with Alpha
ãã¡ã€ã«ã®ãµã€ãºãšç»åã®ãµã€ãºãå€æŽãããããšãç°¡åã«èŠãŠåããŸãã
ããŒã¯ãŒãå±é
SubversionãCVSã䜿ã£ãŠããéçºè ãããããŒã¯ãŒãå±éæ©èœããªã¯ãšã¹ããããããšããããããŸãã ããã§ã®äž»ãªåé¡ã¯ãGit ã§ã¯ãã³ãããã®åŸã«ãã³ãããã«é¢ããæ å ±ã䜿ã£ãŠãã¡ã€ã«ãå€æŽããããšã¯ã§ããªããšããããšã§ããããã¯ãGit ãã³ãããã®æåã«ãã¡ã€ã«ã®ãã§ãã¯ãµã ãçæããããã§ãã ãããããã¡ã€ã«ããã§ãã¯ã¢ãŠãããéã«ããã¹ããæ¿å ¥ããã³ããããžè¿œå ããéã«ãããåé€ããããšã¯å¯èœã§ãã Gitã®å±æ§ã¯ãããè¡ãããã®æ¹æ³ã2ã€æäŸããŸãã
ã²ãšã€ãã®æ¹æ³ãšããŠããã¡ã€ã«ã® $Id$
ãã£ãŒã«ããžã blob ã® SHA-1 ãã§ãã¯ãµã ãèªåçã«æ¿å
¥ã§ããŸãã
ãããã¡ã€ã«ããããã¯ããã€ãã®ãã¡ã€ã«ã«å¯ŸããŠãã®å±æ§ãèšå®ããã°ã次ã«ãã®ãã©ã³ãããã§ãã¯ã¢ãŠãããæãGitã¯ãã®çœ®ãæããè¡ãããã«ãªããŸãã
ãã ããæ¿å
¥ããããã§ãã¯ãµã ã¯ã³ãããã«å¯Ÿãããã®ã§ã¯ãªãã察象ãšãªãblobã®ãã®ã§ãããšããç¹ã«æ³šæããŠäžããã
ã§ã¯ããã§ã以äžã®è¡ã`.gitattributes`ã«è¿œå ããŠã¿ãŸãããã
*.txt ident
ç¶ããŠã`$Id$`ãžã®åç §ããã¹ãçšãã¡ã€ã«ã«è¿œå ããŸãã
$ echo '$Id$' > test.txt
ãããããšã次ã«ãã®ãã¡ã€ã«ããã§ãã¯ã¢ãŠãããæãGitã¯blobã®SHA-1ãã§ãã¯ãµã ãæ¿å ¥ããŸãã
$ rm test.txt
$ git checkout -- test.txt
$ cat test.txt
$Id: 42812b7653c7b88933f8a9d6cad0ca16714b9bb3 $
ãããããã®çµæã¯ããŸã圹ã«ç«ã¡ãŸããã CVSãSubversionã®ããŒã¯ãŒãå±éã§ã¯ã¿ã€ã ã¹ã¿ã³ããå«ããããšãã§ããŸãã察ããŠãSHA-1ãã§ãã¯ãµã ã¯å®å šã«ã©ã³ãã ãªå€ã§ãããã2ã€ã®å€ã®æ°æ§ãç¥ãããã®å©ãã«ã¯ãªããŸããã
ããã«ã¯ãã³ãããããã³ãã§ãã¯ã¢ãŠãã®æã«ããŒã¯ãŒãå±éãè¡ããã£ã«ã¿ãæžããŠããã°å¯Ÿå¿ã§ããŸãã
ãã®ãã£ã«ã¿ã¯ âcleanâ ããã³ âsmudgeâ ãã£ã«ã¿ãšåŒã°ããŸãã
.gitattributes
ãã¡ã€ã«ã§ãç¹å®ã®ãã¹ã«ãã£ã«ã¿ãèšå®ãããã§ãã¯ã¢ãŠãã®çŽåïŒ âsmudgeâ ã ãã§ãã¯ã¢ãŠãããæã« âsmudgeâ ãã£ã«ã¿ãå®è¡ãã ãåç
§ïŒããã³ã¹ããŒãžã³ã°ã®çŽåïŒ âcleanâ ã ã¹ããŒãžã³ã°ããæã« âcleanâ ãã£ã«ã¿ãå®è¡ãã ãåç
§ïŒã«åŠçãè¡ãã¹ã¯ãªãããèšå®ã§ããŸãã
ãããã®ãã£ã«ã¿ã¯ãè²ã
ãšé¢çœãããšã«äœ¿ããŸãã
ãã®æ©èœã«å¯ŸããŠãªãªãžãã«ã®ã³ãããã¡ãã»ãŒãžã¯ç°¡åãªäŸãäžããŠãããŠããŸããããã¯ã³ãããåã«Cã®ãœãŒã¹ã³ãŒãã indent
ããã°ã©ã ã«éããšãããã®ã§ãã
*.c
ãã¡ã€ã«ã«å¯ŸããŠãã®ãã£ã«ã¿ãå®è¡ããããã«ã`.gitattributes`ãã¡ã€ã«ã«filterå±æ§ãèšå®ã§ããŸãã
*.c filter=indent
ãããããsmudgeãšclean㧠âindentâ ãã£ã«ã¿ãäœãè¡ãã°ããã®ããGitã«æããŸãã
$ git config --global filter.indent.clean indent
$ git config --global filter.indent.smudge cat
ãã®ã±ãŒã¹ã§ã¯ã *.c
ã«ããããããã¡ã€ã«ãã³ãããããæãGitã¯ã¹ããŒãžã³ã°åã«indentããã°ã©ã ã«ãã¡ã€ã«ãéãããã§ãã¯ã¢ãŠãããåã«ã¯ cat
ãéãããã«ããŸãã
cat`ã¯åºæ¬çã«äœãããŸãããå
¥åãããããŒã¿ãšåãããŒã¿ãåãåºãã ãã§ãã
ãã®çµã¿åããã䜿ãã°ãCã®ãœãŒã¹ã³ãŒãã®ã³ãããåã«ãå¹æçã« `indent
ãéããŸãã
ããã²ãšã€ã®èå³æ·±ãäŸãšããŠãRCSã¹ã¿ã€ã«ã® $Date$
ããŒã¯ãŒãå±éããããŸãã
ãããæ£ããè¡ãã«ã¯ããã¡ã€ã«åãåãåãããããžã§ã¯ãã®ææ°ã®ã³ãããã®æ¥ä»ãèŠãŠããã®æ¥ä»ããã¡ã€ã«ã«æ¿å
¥ããã¡ãã£ãšããã¹ã¯ãªãããå¿
èŠã«ãªããŸãã
ãããè¡ãRubyã¹ã¯ãªããã以äžã«ç€ºããŸãã
#! /usr/bin/env ruby
data = STDIN.read
last_date = `git log --pretty=format:"%ad" -1`
puts data.gsub('$Date$', '$Date: ' + last_date.to_s + '$')
ãã®ã¹ã¯ãªããã¯ãgit log
ã³ãã³ãã®åºåããææ°ã®ã³ãããã®æ¥ä»ãååŸããæšæºå
¥åäžã®ãã¹ãŠã® $Date$
æååã«ãã®æ¥ä»ãè¿œå ããçµæãåºåããŸãããæ°ã«å
¥ãã®ã©ããªèšèªã§æžãã«ããŠããç°¡åãªã¹ã¯ãªããã«ãªãã§ãããã
ãã®ã¹ã¯ãªãããã¡ã€ã«ã«`expand_date`ãšååãã€ããå®è¡ãã¹ã®ã©ããã«çœ®ããŸãã
次ã«ãGit ã«ãã£ã«ã¿ïŒããã§ã¯ dater`ãšããŸãïŒãèšå®ãããã§ãã¯ã¢ãŠãæã« smudge 㧠`expand_date
ãã£ã«ã¿ã䜿ãããã«æå®ããŸãã
ã³ãããæã«æ¥ä»ãåé€ããã®ã«ã¯ã Perl ã®æ£èŠè¡šçŸã䜿ããŸãã
$ git config filter.dater.smudge expand_date
$ git config filter.dater.clean 'perl -pe "s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"'
ãã®Perlã®ã¹ããããã¯ã $Date$
æååã®å
åŽã«ããå
容ãåé€ããæ¥ä»ãæ¿å
¥ããåã®ç¶æ
ã«æ»ããŸãã
ããŠããã£ã«ã¿ã®æºåãã§ããŸããããã®ãã¡ã€ã«ãæ°ãããã£ã«ã¿ã«åŒã£ãããããã« Git ã®å±æ§ãèšå®ãããã¡ã€ã«ã« $Date$
ããŒã¯ãŒããè¿œå ããäžã§ããã¹ãããŠã¿ãŸãããã
date*.txt filter=dater
$ echo '# $Date$' > date_test.txt
ãããã®å€æŽãã³ãããããŠãå床ãã¡ã€ã«ããã§ãã¯ã¢ãŠãããã°ãããŒã¯ãŒããæ£ãã眮ãæããããŠããã®ãããããŸãã
$ git add date_test.txt .gitattributes
$ git commit -m "Testing date expansion in Git"
$ rm date_test.txt
$ git checkout date_test.txt
$ cat date_test.txt
# $Date: Tue Apr 21 07:26:52 2009 -0700$
ã¢ããªã±ãŒã·ã§ã³ã®ã«ã¹ã¿ãã€ãºã«ãããããã®ãã¯ããã¯ãã©ãã»ã©åŒ·åããããããããã ãããšæããŸãã
ãããã泚æããŠã»ããã®ã§ããã .gitattributes
ãã¡ã€ã«ã¯ã³ããããããŠãããžã§ã¯ãå
ã§å
±æãããŸããããã©ã€ãïŒãã®ã±ãŒã¹ã§èšãã°ãdater
ïŒããã¯ããã¯ãããŸããããã®ããããã®æ©èœã¯ã©ãã§ã§ãåãããã§ã¯ãããŸããã
ãã£ã«ã¿ãèšèšããæã«ã¯ãããšããã£ã«ã¿ãæ£åžžã«åäœããªãã£ããšããŠãããããžã§ã¯ãã¯é©åã«åãç¶ããããããã«ãã¹ãã§ãã
ãªããžããªããšã¯ã¹ããŒããã
ããªãã®ãããžã§ã¯ãã®ã¢ãŒã«ã€ãããšã¯ã¹ããŒãããæã«ã¯ãGitã®å±æ§ããŒã¿ã䜿ã£ãŠèå³æ·±ãããšãã§ããŸãã
export-ignore
ã¢ãŒã«ã€ããçæãããšããç¹å®ã®ãã¡ã€ã«ããã£ã¬ã¯ããªããšã¯ã¹ããŒãããªãããã«èšå®ã§ããŸãã
ãããžã§ã¯ãã«ã¯ãã§ãã¯ã€ã³ãããããã¢ãŒã«ã€ããã¡ã€ã«ã«ã¯å«ããããªããã£ã¬ã¯ããªããã¡ã€ã«ããããªãããããã« export-ignore
å±æ§ãèšå®ããããšã§ãåå¥ãè¡ããŸãã
äŸãã°ããããžã§ã¯ãããšã¯ã¹ããŒãããéã« tarball ã«å«ããããªããã¹ããã¡ã€ã«ãã `test/`ãã£ã¬ã¯ããªä»¥äžã«å ¥ã£ãŠãããšããŸãããã ãã®å Žåã次ã®1è¡ãGitã®å±æ§ãã¡ã€ã«ã«è¿œå ããŸãã
test/ export-ignore
ããã§ããããžã§ã¯ãã®tarballãäœæããããã« git archive
ãå®è¡ããæãã¢ãŒã«ã€ãã«ã¯ test/
ãã£ã¬ã¯ããªãå«ãŸããªãããã«ãªããŸãã
export-subst
ãããã€çšã«ãã¡ã€ã«ããšã¯ã¹ããŒãããéã«ãexport-subst
å±æ§ã®ã€ãããã¡ã€ã«ãæå®ã㊠git log
ã®ãã°æžåŒæå®æ©èœãšããŒã¯ãŒãå±éæ©èœã§çæããå
容ããã¡ã€ã«ã«ä»äžã§ããŸãã
äŸãã°ãLAST_COMMIT`ãšããååã®ãã¡ã€ã«ããããžã§ã¯ãã«è¿œå ãã`git archive`ãå®è¡ããæã«ãã®ãã¡ã€ã«ã®ã¡ã¿ããŒã¿ãææ°ã³ããããšåãå
容ã«å€æãããå Žåã
.gitattributes`ãã¡ã€ã«ãš`LAST_COMMIT`ãã¡ã€ã«ã
次ã®ããã«èšå®ããŸãã
LAST_COMMIT export-subst
$ echo 'Last commit date: $Format:%cd by %aN$' > LAST_COMMIT
$ git add LAST_COMMIT .gitattributes
$ git commit -am 'adding LAST_COMMIT file for archives'
git archive
ãå®è¡ãããšã LAST_COMMIT
ã¯ä»¥äžã®ãããªå
容ã«ãªã£ãŠããã¯ãã§ãã
$ git archive HEAD | tar xCf ../deployment-testing -
$ cat ../deployment-testing/LAST_COMMIT
Last commit date: Tue Apr 21 08:38:48 2009 -0700 by Scott Chacon
ãã®ãããªçœ®æã«ãã³ãããã¡ãã»ãŒãžã git note ãçšããããšãã§ããŸãããã®éãgit log ã³ãã³ãã®ã¯ãŒãã©ããåŠçãé©çšãããŸãã
$ echo '$Format:Last commit: %h by %aN at %cd%n%+w(76,6,9)%B$' > LAST_COMMIT
$ git commit -am 'export-subst uses git log's custom formatter
git archive uses git log's `pretty=format:` processor
directly, and strips the surrounding `$Format:` and `$`
markup from the output.
'
$ git archive @ | tar xfO - LAST_COMMIT
Last commit: 312ccc8 by Jim Hill at Fri May 8 09:14:04 2015 -0700
export-subst uses git log's custom formatter
git archive uses git log's `pretty=format:` processor directly, and
strips the surrounding `$Format:` and `$` markup from the output.
ãã®çµæäœæãããã¢ãŒã«ã€ãã¯ãããã€ããã®ã«ãŽã£ããã§ããäžæ¹ããã£ãããšã¯ã¹ããŒããããŠããŸã£ãã¢ãŒã«ã€ãã§éçºãç¶ããã®ã¯ããããã§ããŸããã
ããŒãžã®æŠç¥
Gitã®å±æ§ã䜿ãã°ããããžã§ã¯ãäžã®ç¹å®ã®ãã¡ã€ã«ã«å¯ŸããŠãç°ãªãããŒãžæŠç¥ã䜿ãããšãã§ããŸãã éåžžã«æçšãªãªãã·ã§ã³ã®ã²ãšã€ã«ãæå®ãããã¡ã€ã«ã§ç«¶åãçºçããå Žåã«ãããŒãžãè¡ããã«ãããªãã®å€æŽå 容ã§ä»ã®èª°ãã®å€æŽãäžæžãããããã«èšå®ãããšãããã®ããããŸãã
ããã¯ãããžã§ã¯ãã«ãããŠãåå²ãããã©ã³ãããç¹å¥çã®ãã©ã³ãã§äœæ¥ãããŠããæããã®ãã©ã³ãã§ã®å€æŽãããŒãžããããããç¹å®ã®ãã¡ã€ã«ã®å€æŽã¯ãªãã£ãããšã«ããããšãããããªæã«å©ãã«ãªããŸãã
äŸãã°ã database.xml
ãšããããŒã¿ããŒã¹ã®èšå®ãã¡ã€ã«ãããããµãã€ã®ãã©ã³ãã§ãã®å
容ãç°ãªã£ãŠãããšããŸãããããããŠããã®ããŒã¿ããŒã¹ãã¡ã€ã«ãå°ç¡ãã«ããããšãªãã«ãäžæ¹ã®ãã©ã³ããžãšããŒãžããããšããŸãã
ããã¯ã次ã®ããã«å±æ§ãèšå®ããã°å®çŸã§ããŸãã
database.xml merge=ours
ãã®äžã§ããããŒã®ããŒãžæŠç¥ ours
ã次ã®ããã«å®çŸ©ããŸãã
$ git config --global merge.ours.driver true
ããäžæ¹ã®ãã©ã³ãã§ããŒãžãå®è¡ãããšã database.xml
ã«é¢ãã競åã¯çºçããã次ã®ãããªçµæã«ãªããŸãã
$ git merge topic
Auto-merging database.xml
Merge made by recursive.
ãã®å Žåã database.xml
ã¯å
ã
ã®ããŒãžã§ã³ã®ãŸãŸãæžãå€ãããŸããã