• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

CentOS上からgithubを使えるようにしたので作業内容をメモ。

まずはyumでgitをインストールします。ちなみにCentOSのバージョンは5.8です。

sh>>

yum install git

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: rsync.atworks.co.jp
  • epel: ftp.iij.ad.jp
  • extras: rsync.atworks.co.jp
  • remi: rpms.famillecollet.com
  • updates: rsync.atworks.co.jp
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package git.x86_64 0:1.7.4.1-1.el5 set to be updated
    --> Processing Dependency: perl-Git = 1.7.4.1-1.el5 for package: git
    --> Processing Dependency: rsync for package: git
    --> Processing Dependency: perl(Error) for package: git
    --> Processing Dependency: perl(Git) for package: git
    --> Running transaction check
    ---> Package perl-Error.noarch 1:0.17010-1.el5 set to be updated
    ---> Package perl-Git.x86_64 0:1.7.4.1-1.el5 set to be updated
    ---> Package rsync.x86_64 0:3.0.6-4.el5_7.1 set to be updated
    --> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
Package Arch Version Repository Size

Installing:
git x86_64 1.7.4.1-1.el5 epel 4.5 M
Installing for dependencies:
perl-Error noarch 1:0.17010-1.el5 epel 26 k
perl-Git x86_64 1.7.4.1-1.el5 epel 28 k
rsync x86_64 3.0.6-4.el5_7.1 base 347 k

Transaction Summary

Install 4 Package(s)
Upgrade 0 Package(s)

Total download size: 4.9 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): perl-Error-0.17010-1.el5.noarch.rpm | 26 kB 00:00
(2/4): perl-Git-1.7.4.1-1.el5.x86_64.rpm | 28 kB 00:00
(3/4): rsync-3.0.6-4.el5_7.1.x86_64.rpm | 347 kB 00:00
(4/4): git-1.7.4.1-1.el5.x86_64.rpm | 4.5 MB 00:00

Total 4.1 MB/s | 4.9 MB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-Error 1/4
Installing : rsync 2/4
Installing : git 3/4
Installing : perl-Git 4/4

Installed:
git.x86_64 0:1.7.4.1-1.el5

Dependency Installed:
perl-Error.noarch 1:0.17010-1.el5 perl-Git.x86_64 0:1.7.4.1-1.el5 rsync.x86_64 0:3.0.6-4.el5_7.1

Complete!
<<--

続いてgithubのヘルプページを参考にして環境設定。
まずはコミット時に使うユーザ名とメールアドレスを設定します。

sh>>
$ git config --global user.name "h-akanuma"
$ git config --global user.email "hiroaki.akanuma@gmail.com"
<<--

メールアドレスは正しいメールアドレスを設定する必要はなくて、コミットを識別するためのものなので、user@server のような形にしてどこからのコミットかを判別できるようにしても良いらしいです。

次はパスワードのキャッシュ設定。リモートサーバにアクセスするたびにパスワードを入力しなくても良いように、パスワードをキャッシュする設定をします。また、デフォルトのキャッシュの有効期限は15分間なので、とりあえず1時間に変更しておきます。

sh>>
$ git config --global credential.helper cache
$ git config --global credential.helper 'cache --timeout=3600'
<<--

これだけでひとまず全体的な設定は終了なので、ブラウザでgithubにアクセスして新しくリポジトリを作成します。

そして再びCentOS上での作業です。バージョン管理対象にするディレクトリを作成して初期化します。

sh>>
$ mkdir PerlTools
$ cd PerlTools/
$ git init
Initialized empty Git repository in /home/akanuma/scripts/PerlTools/.git/
<<--

バージョン管理したいファイルを作成し、ローカルリポジトリにコミットします。

sh>>
$ cp ../cut_time.pl .
$ ls -la
合計 16
drwxrwxr-x 3 akanuma akanuma 4096 6月 10 00:29 .
drwxrwxr-x 3 akanuma akanuma 4096 6月 10 00:28 ..
drwxrwxr-x 7 akanuma akanuma 4096 6月 10 00:28 .git
-rw-rw-r-- 1 akanuma akanuma 1336 6月 10 00:29 cut_time.pl
$
$ git add cut_time.pl
$ git commit -m 'Script for cutting file content by time range'
[master (root-commit) a677816] Script for cutting file content by time range
1 files changed, 75 insertions(+), 0 deletions(-)
create mode 100644 cut_time.pl
<<--

そしてローカルリポジトリへのコミット内容をgithubへpushします。

sh>>
$ git remote add origin https://github.com/h-akanuma/PerlTools.git
$ git push origin master
Username:
Password:
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 757 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/h-akanuma/PerlTools.git

  • [new branch] master -> master
    <<--

これでgithubへコミット内容が反映されました。
他のリポジトリのForkはまだやっていないのでまたそのうち。

posted by akanuma akanuma on Sun 10 Jun 2012 at 00:54 with 0 comments