æè¿Gitã«å¤¢ä¸ã§ãããã®ã§ä¸ã«åºããããã«ã¡ã¢ç¨åº¦ã«ã¨ã³ããªã¼ãæ®ããã¨ã«ãã¾ãã
å
容ã¯çµæ§ãããµããªã®ã§ééã£ã¦ããããããããã¾ãããã¤ã£ããã§ããã ããã¨veryæè¬ããªããä¿®æ£ãã¾ãã
åæã¨ãã¦ç°å¢ã¯Debian sid,etchãMac OSX/Leopardã¨ãã¾ãã
Gitã¨ã¯ä½ãï¼
Git(ã¸ããããããã¯ã®ãã)ã¯Linux kernelã®ã½ã¼ã¹ã³ã¼ãã管çããããã«Linus Torvaldsãéçºãããªã¼ãã³ã½ã¼ã¹ã®ãã¼ã¸ã§ã³ç®¡çã·ã¹ãã ã§ãã
巨大ãªããã¸ã§ã¯ããç´ æ©ãå¹ççã«æ±ããããã«ãã¶ã¤ã³ããã¦ãããMercurialãBazzarã®æ§ãªåæ£åã®SCM(Source Code Management)ã«åé¡ããã¾ãã
- å ¬å¼ãµã¤ã
- Git
ã¤ã³ã¹ãã¼ã«
etchã®git-coreããã±ã¼ã¸ã§ã¯Gitã®ãã¼ã¸ã§ã³ã1.4ç³»å*1ãªã®ã§ã1.5ç³»åã使ãããã«backportsã使ãã¾ããã¾ãã404 Not Foundãåèã«source.listã«backportsã追å ãããã¨ãaptitudeã§ã¤ã³ã¹ãã¼ã«ãã¾ãã
Debianã§ã¯gitã®ããã±ã¼ã¸ãGitæ¬ä½ã¨ã³ã¢ã®æ©è½ã®ã¿ã®git-coreã¨ãã®ä»ã®æ©è½ã®ããã±ã¼ã¸ã§ãããã¦ãã¾ããgit-coreããã±ã¼ã¸ä»¥å¤ã«å¿
è¦ãªãã®ã¯å
¥ãã¦ããã¨ããã§ãã
ä»åã¯git-cvsãgit-svnãgit-emailãå
¥ãããã¨ã«ãã¾ãã
$ sudo aptitude install -t etch-backports git-core git-cvs git-svn git-email
ããã§ã¤ã³ã¹ãã¼ã«ã¯å®äºã§ãã
- Debian sidã®å ´å
sidã®ããã±ã¼ã¸ã¯1.5ç³»åãªã®ã§ãã®ã¾ã¾ã¤ã³ã¹ãã¼ã«ã§ãã¾ãã
$ sudo aptitude install git-core git-cvs git-svn git-email
- Leopardã®å ´å
Macportsã«ããã±ã¼ã¸ãããã®ã§ãããå
¥ãã¾ãã
$ sudo port install git - mobcoããã®ææã«ããè¨æ£('08/05/14)
$ sudo port install git-core
以ä¸ãç°¡åãmac++
ã¨ããããã®è¨å®
ååã¨ã¡ã¼ã«ã¢ãã¬ã¹ãè¨å®ãã¦ããã¾ãã
$ git congig --global user.name 'your name' - ujihisaããã®ææã«ããè¨æ£('08/05/15)
$ git config --global user.name 'your name' $ git config --global user.email [email protected]
ããã¨~/.gitconfigã«ä»¥ä¸ã®æ§ã«æ¸ãè¾¼ã¾ãã¾ãã
[user] name = your name email = [email protected]
ä»ã®è¨å®é ç®ã«ã¤ãã¦ã¯ã'man git-config'ã§èª¿ã¹ããã¾ãã
Gitã®manãã¼ã¸ã¯ã³ãã³ããã¨ã«å¥ãã¦ãã¦ãä¾ãã°'git init'ã³ãã³ãã«ã¤ãã¦èª¿ã¹ãå ´åã¯'man git-init'ã§èª¿ã¹ããã¾ãã*2
ããã¸ã§ã¯ãã®ã¤ã³ãã¼ã
以ä¸ã®æé ã§myprojããã¸ã§ã¯ããéå§ãã¾ãã
$ mkdir myproj $ cd myproj $ git init Initialized empty Git repository in .git/
ããã§myprojãã£ã¬ã¯ããªã®ä¸ã«.gitã¨ãããã£ã¬ã¯ããªãä½æãããgité¢é£ã®ãã®ã¯ããã«ç½®ãããããã«ãªãã¾ãã
ãã§ã«ãããã£ã¬ã¯ããªå
ã§ã'git init'ãããã¨ã«ãã£ã¦gitãªãã¸ããªã«åãè¾¼ããã¨ãå¯è½ã§ãã
ããã¸ã§ã¯ãã®ç¶æ ãç¥ã
myprojããã¸ã§ã¯ãã®ç¶æ ãè¦ãã«ã¯'git status'ã使ãã¾ãã
$ git status # On branch master # # Initial commit # nothing to commit (create/copy files and use "git add" to track)
ç¾å¨ã¯ã¾ã ä½ããã¡ã¤ã«ããªãã®ã§ãã¾ãè¦ãã¹ãã¨ããã¯ãªãã®ã§ãããããã§æ³¨ç®ã¯'On branch master'ã®é¨åãããã¯ç¾å¨ã®Branchã'master'ã§ãããã¨ã示ãã¦ãã¾ããããã¯å¾ã»ã©Branchã®è©±ãããã¨ã詳ããæ¸ãã¾ãã
ãã¡ã¤ã«ã追å ãã¦ã¿ã
myprojããã¸ã§ã¯ãã«ã¯ã¾ã ä½ããã¡ã¤ã«ãããã¾ãããããã§ã¯ã¤ã¾ããªãã®ã§ä½ããã¡ã¤ã«ã追å ãã¾ãããã
ä»åã¯'Hi, git!'ã¨è¡¨ç¤ºããããã°ã©ã ãRubyã§æ¸ãã¾ããã
$ vim greet.rb (ç·¨é) $ cat greet.rb puts 'Hi, git!'
ã§ã¯ããã¸ã§ã¯ãã®ç¶æ ãè¦ã¦ã¿ã¾ãããã
$ git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # greet.rb nothing added to commit but untracked files present (use "git add" to track)
å 容ãååã¨å¤ããã¾ããã'Untrackd files'ã¨ããé ç®ãå¢ãã¦ã¾ãããããã¯gitã追跡ãã¦ããªããã¡ã¤ã«ã®ãªã¹ã¨ã§ãã'git add'ã使ã£ã¦ã³ãããããããã¡ã¤ã«ã«å«ããªããã¨æ¸ãã¦ããã®ã§å¾ãã¾ãã*3
$ git add greet.rb $ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: greet.rb #
ããã§greet.rbãã³ãããå¾
ã¡ã¨ãªãã¾ããããã¡ã¤ã«ã®è¿½å ãªã®ã§'new file'ã¨ãªã£ã¦ãããå¤æ´ããå ´åã¯'modified'ã«ãªãã¾ã
ãã£ã¬ã¯ããªä¸ã®ãã¹ã¦ã®ãã¡ã¤ã«ãaddããã«ã¯'git add .'ã¨ãã¾ããè«ãããã§ãã詳ããã¯'man git-add'ã§ã
ã³ããããã
ã§ã¯'greet.rb'ãã³ããããã¦ã¿ã¾ãããã
$ git commit greet.rb -m 'initial commit' Created initial commit db58434: initial commit 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 greet.rb $ git status # On branch master nothing to commit (working directory clean)
ãªãã·ã§ã³'-m'以ä¸ã¯ã³ãããã¡ãã»ã¼ã¸ã¨ãªã£ã¦ãã¾ããä»åã¯åãã¦ã®ã³ããããªã®ã§'initial commit'ã¨ãã¾ããããé常ã¯å¤æ´ã®å 容ãæ¸ãã¾ãããã®ãªãã·ã§ã³ãã¤ããªãã£ãå ´åã¯ã¨ãã£ã¿ãéãã¦ãããã§ã³ãããã¡ãã»ã¼ã¸ãæ¸ããã¨ã«ãªãã¾ããå¤æ´ãããã¡ã¤ã«ããã¹ã¦ã³ãããããæã¯'-a'ãªãã·ã§ã³ãã¤ãã¾ãã
é·ãã®ã§åå²ãã¾ãã次åã¯ãã®ç¶ãããã
('08/05/14 追è¨: Macã§ã®Gitããã±ã¼ã¸ãgitã¨ãã¦ããã®ãgit-coreã«ä¿®æ£ thx mobcovãã)
('08/05/14 追è¨: ã¤ã³ã¹ãã¼ã«ã®é
ç®ã§Debianã®sidã¨etchãåéããã¦ãã®ã§ä¿®æ£)
('08/05/15 追è¨: git configãgit congigã«ãã¦ããã®ãä¿®æ£ thx ujihisaãã)