git(ギット)とは? †
- バージョン管理システム
- 公式サイト: http://git-scm.com/
- 必要となる知識: Linux, vim
- 動作環境: Linuxローカル環境(CentOS 5.11 - 32bit)
gitインストール †
# yum -y update
# yum -y install git
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
No package git available.
Nothing to do
- yum install git失敗のためEPELリポジトリをインストール
# wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -ivh epel-release-5-4.noarch.rpm
# vi /etc/yum.repos.d/epel.repo
--------------------
[epel]
...
enabled=1
priority=1
...
--------------------
# yum -y install git
# git --version
git version 1.8.2.1
バージョン管理の流れ †
- 作業ディレクトリ
- ステージングエリア(インデックス)
- リポジトリ(ローカル、リモート)
gitの設定 †
$ git config --global user.name "Yuji Shimojo"
$ git config --global user.email "yjshimojo@gmail.com"
$ git config --global color.ui true
$ git config -l
user.name=Yuji Shimojo
user.email=yjshimojo@gmail.com
color.ui=true
$ git config --help
$ git help config
リポジトリへのコミット †
$ mkdir myweb
$ cd myweb/
$ git init
Initialized empty Git repository in /home/yuji/myweb/.git/
$ vi index.html
--------------------
line 1
--------------------
$ cat index.html
line 1
- 作業ディレクトリ=>ステージングエリアへファイルをアップ
$ git add index.html
- ステージングエリア=>リポジトリへファイルをアップ
$ git commit
--------------------
initial commit // コミットメッセージ(任意)
--------------------
[master (root-commit) 12662e4] initial commit
1 file changed, 1 insertion(+)
create mode 100644 index.html
$ git log
commit 12662e4f226f299708ddb5c89274739fd355f9b8
Author: Yuji Shimojo <yjshimojo@gmail.com>
Date: Sun Sep 20 03:03:31 2015 +0900
initial commit