バージョンコントロールとしてGitをインストール、初期設定

Ruby on RailsアプリのバージョンコントロールシステムとしてGitをインストール、初期設定する手順をまとめました。

1)yumコマンドでgitをインストール
 

# yum install git

Installed:
  git.x86_64 0:1.7.1-3.el6_4.1

Dependency Installed:
  openssh-clients.x86_64 0:5.3p1-84.1.el6   perl-Error.noarch 1:0.17015-4.el6
  perl-Git.noarch 0:1.7.1-3.el6_4.1         rsync.x86_64 0:3.0.6-9.el6

Dependency Updated:
  openssh.x86_64 0:5.3p1-84.1.el6     openssh-server.x86_64 0:5.3p1-84.1.el6
  zlib.x86_64 0:1.2.3-29.el6          zlib-devel.x86_64 0:1.2.3-29.el6

Complete!

 
2)Gitのシステム全体の初期設定
 
$ git config –global user.name “Your Name” $ git config –global user.email your.email@example.com
 
3)アプリケーション作成
 
$ rails new sample_app
 
4)Gitのリポジトリ作成
 

$ cd sample_app
$ git init
Initialized empty Git repository in /home/rails/rails_projects/first_app/.git/

 
5)Gitで管理対象外とするファイルの設定
 

$ vi .gitignore

下記記述を追加
# Ignore other unneeded files.
doc/
*.swp
*~
.project
.DS_Store
.idea

 
6)新リポジトリにファイルを追加
 

$ git add .
$ git status

# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#       new file:   .gitignore
#       new file:   Gemfile
#       new file:   Gemfile.lock
#       new file:   README.rdoc
#       new file:   Rakefile
#       new file:   app/assets/images/rails.png
#       new file:   app/assets/javascripts/application.js
      :
</file>

 
7)Gitでコミット
 

$ git commit -m "Initial commit"

[master (root-commit) 27ad48e] Initial commit
 36 files changed, 1213 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 Gemfile
 create mode 100644 Gemfile.lock
 create mode 100644 README.rdoc
 create mode 100644 Rakefile
 create mode 100644 app/assets/images/rails.png
 create mode 100644 app/assets/javascripts/application.js

 
8)ログで確認
 

$ git log

commit 27ad48e924c0e2・・・・
Author: testadmin
Date:   Fri Mar 22 15:50:14 2013 +0900

    Initial commit

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です