CentOS上からgithubを使えるようにしたので作業内容をメモ。
まずはyumでgitをインストールします。ちなみにCentOSのバージョンは5.8です。
1
2 Loaded plugins: fastestmirror
3 Loading mirror speeds from cached hostfile
4 * base: rsync.atworks.co.jp
5 * epel: ftp.iij.ad.jp
6 * extras: rsync.atworks.co.jp
7 * remi: rpms.famillecollet.com
8 * updates: rsync.atworks.co.jp
9 Setting up Install Process
10 Resolving Dependencies
11 --> Running transaction check
12 ---> Package git.x86_64 0:1.7.4.1-1.el5 set to be updated
13 --> Processing Dependency: perl-Git = 1.7.4.1-1.el5 for package: git
14 --> Processing Dependency: rsync for package: git
15 --> Processing Dependency: perl(Error) for package: git
16 --> Processing Dependency: perl(Git) for package: git
17 --> Running transaction check
18 ---> Package perl-Error.noarch 1:0.17010-1.el5 set to be updated
19 ---> Package perl-Git.x86_64 0:1.7.4.1-1.el5 set to be updated
20 ---> Package rsync.x86_64 0:3.0.6-4.el5_7.1 set to be updated
21 --> Finished Dependency Resolution
22
23 Dependencies Resolved
24
25 ========================================================================================================================
26 Package Arch Version Repository Size
27 ========================================================================================================================
28 Installing:
29 git x86_64 1.7.4.1-1.el5 epel 4.5 M
30 Installing for dependencies:
31 perl-Error noarch 1:0.17010-1.el5 epel 26 k
32 perl-Git x86_64 1.7.4.1-1.el5 epel 28 k
33 rsync x86_64 3.0.6-4.el5_7.1 base 347 k
34
35 Transaction Summary
36 ========================================================================================================================
37 Install 4 Package(s)
38 Upgrade 0 Package(s)
39
40 Total download size: 4.9 M
41 Is this ok [y/N]: y
42 Downloading Packages:
43 (1/4): perl-Error-0.17010-1.el5.noarch.rpm | 26 kB 00:00
44 (2/4): perl-Git-1.7.4.1-1.el5.x86_64.rpm | 28 kB 00:00
45 (3/4): rsync-3.0.6-4.el5_7.1.x86_64.rpm | 347 kB 00:00
46 (4/4): git-1.7.4.1-1.el5.x86_64.rpm | 4.5 MB 00:00
47 ------------------------------------------------------------------------------------------------------------------------
48 Total 4.1 MB/s | 4.9 MB 00:01
49 Running rpm_check_debug
50 Running Transaction Test
51 Finished Transaction Test
52 Transaction Test Succeeded
53 Running Transaction
54 Installing : perl-Error 1/4
55 Installing : rsync 2/4
56 Installing : git 3/4
57 Installing : perl-Git 4/4
58
59 Installed:
60 git.x86_64 0:1.7.4.1-1.el5
61
62 Dependency Installed:
63 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
64
65 Complete!
続いてgithubのヘルプページを参考にして環境設定。
まずはコミット時に使うユーザ名とメールアドレスを設定します。
1 $ git config --global user.name "h-akanuma"
2 $ git config --global user.email "hiroaki.akanuma@gmail.com"
メールアドレスは正しいメールアドレスを設定する必要はなくて、コミットを識別するためのものなので、user@server のような形にしてどこからのコミットかを判別できるようにしても良いらしいです。
次はパスワードのキャッシュ設定。リモートサーバにアクセスするたびにパスワードを入力しなくても良いように、パスワードをキャッシュする設定をします。また、デフォルトのキャッシュの有効期限は15分間なので、とりあえず1時間に変更しておきます。
1 $ git config --global credential.helper cache
2 $ git config --global credential.helper 'cache --timeout=3600'
これだけでひとまず全体的な設定は終了なので、ブラウザでgithubにアクセスして新しくリポジトリを作成します。
そして再びCentOS上での作業です。バージョン管理対象にするディレクトリを作成して初期化します。
1 $ mkdir PerlTools
2 $ cd PerlTools/
3 $ git init
4 Initialized empty Git repository in /home/akanuma/scripts/PerlTools/.git/
バージョン管理したいファイルを作成し、ローカルリポジトリにコミットします。
1 $ cp ../cut_time.pl .
2 $ ls -la
3 合計 16
4 drwxrwxr-x 3 akanuma akanuma 4096 6月 10 00:29 .
5 drwxrwxr-x 3 akanuma akanuma 4096 6月 10 00:28 ..
6 drwxrwxr-x 7 akanuma akanuma 4096 6月 10 00:28 .git
7 -rw-rw-r-- 1 akanuma akanuma 1336 6月 10 00:29 cut_time.pl
8 $
9 $ git add cut_time.pl
10 $ git commit -m 'Script for cutting file content by time range'
11 [master (root-commit) a677816] Script for cutting file content by time range
12 1 files changed, 75 insertions(+), 0 deletions(-)
13 create mode 100644 cut_time.pl
そしてローカルリポジトリへのコミット内容をgithubへpushします。
1 $ git remote add origin https://github.com/h-akanuma/PerlTools.git
2 $ git push origin master
3 Username:
4 Password:
5 Counting objects: 3, done.
6 Compressing objects: 100% (2/2), done.
7 Writing objects: 100% (3/3), 757 bytes, done.
8 Total 3 (delta 0), reused 0 (delta 0)
9 To https://github.com/h-akanuma/PerlTools.git
10 * [new branch] master -> master
これでgithubへコミット内容が反映されました。
他のリポジトリのForkはまだやっていないのでまたそのうち。