CPI サーバーにリモートリポジトリを作成する方法(Mac)
目次
CPI サーバーにリモートリポジトリを作成する方法
ここでは Mac のターミナルを使って、 CPI サーバーにリモートリポジトリを作成する方法を説明します。
以下、コマンド文は行頭に「$」、コマンド実行後の応答文は行頭に「>」で表示します。
1
Mac 上で【移動】>【ユーティリティ】>【ターミナル】から「ターミナル」を起動し、ローカルリポジトリにするフォルダに移動します
2
以下のコマンドを実行し、お客さま環境で Git の最低限の設定をします
※あらかじめ Mac に Git プログラムがインストールされている必要があります。
※「Your Name」と「you@example.com」にはお客さまにてご指定ください。
- $ git config --global user.name "Your Name"
- $ git config --global user.email you@example.com
3
CPI サーバーに SSH でログインします
※それぞれの区切りに半角スペースが必要ですのでご注意ください。
- $ ssh -l ウェブコントロールパネルID -p SSHのポート番号 ドメイン名(または IP アドレス)
- > Password:
※SSH のパスワードを入力します。入力しても文字は表示されません。
4
CPI サーバーでリモートリポジトリにするディレクトリに移動します
※ここではお客さま環境("/usr/home/ウェブコントロールパネル ID/")直下に「repo」というディレクトリを作成し、リモートリポジトリの設定を行います。
1.「repo」ディレクトリを作成
- $ mkdir repo
2.「repo」ディレクトリに移動
- $ cd repo
3.リモートリポジトリを作成
bare の手前の「--」は半角ハイフンが 2 つ
- $ git init --bare
正常に作成できたら以下のメッセージが表示されます
- > Initialized empty Git repository in /usr/home/*******/repo/
※「*******」にはウェブコントロールパネル ID が表示されます。
CPI サーバーで、 HTTP/HTTPS プロトコル経由の clone や pull をする場合には、CPI サーバーでリモートリポジトリを作成したあと、以下のコマンドを実行してください。
$ git update-server-info
$ mv ./hooks/post-update.sample ./hooks/post-update
$ chmod +x ./hooks/post-update
お客さま環境(ローカルリポジトリ)に CPI サーバー のリモートリポジトリを clone する方法
5
お客さま環境でローカルリポジトリにするディレクトリを作成します
1.お客さま環境の任意の場所に「local-repo」ディレクトリの作成
- $ mkdir local-repo
2.「local-repo」ディレクトリに移動
- $ cd local-repo
6
リモートリポジトリを clone する
■SSH 経由で clone する場合
- $ git clone ssh://ウェブコントロールパネルID@ドメイン名(または IP アドレス):SSHポート番号/usr/home/ウェブコントロールパネルID/repo/
※上記の "/usr/home/ウェブコントロールパネル ID/repo/" で、"ウェブコントロールパネル ID/" 以降は CPI サーバーのリモートリポジトリの場所によって異なりますので、ご注意ください。
■HTTP/HTTPS 経由で clone する場合
- $ git clone http://ドメイン名(または IP アドレス)/repo
※HTTP/HTTPS 経由の場合は、リモートリポジトリがドキュメントルート配下に作成されている必要があります。
お客さま環境のローカルリポジトリでファイルを作成し add(索引に追加) したのち commit する方法
7
お客さま環境(ローカルリポジトリ)で、ファイル(test.txt)を作成
- $ touch test.txt
ステータスを確認するには「git status」を実行します。
- $ git status
- > On branch master
- > Initial commit
- > Untracked files:
- > (use "git add <file>..." to include in what will be committed)
- > test.txt
- > nothing added to commit but untracked files present (use "git add" to track)
2
作成したファイルを add(索引に追加)します。
- $ git add test.txt
- $ git status
- >On branch master
- >Initial commit
- >Changes to be committed:
- (use "git rm --cached <file>..." to unstage)
- >new file: test.txt
9
コミットします
- $ git commit -m "first commit"
※「first commit」の箇所は、任意の文字をご指定ください。
日本語などの全角文字を入力されますと文字化けする場合があります。
- $ git status
- >On branch master
- >Your branch is based on 'origin/master', but the upstream is gone.
- (use "git branch --unset-upstream" to fixup)
- >nothing to commit, working directory clean
10
お客さま環境のローカルリポジトリに加えた変更を CPI サーバー のリモートリポジトリに push します
- $ git push -u origin master
- >Password:
※パスワードは、 SSH アカウントのパスワードです。
11
CPI サーバー(リモートリポジトリ)に SSH 接続し、該当ディレクトリに移動後、以下のコマンドを実行すると変更履歴(ログ)をご確認いただけます
- $ git log
- >commit 1a37473053c0b57r616f86df3de2e24135ef070e
- >Author: Your Name <you@example.com>
- >Date: Wed Oct 8 14:27:52 2014 +0900
- > first commit
更新日 / 2022 年 9 月 29 日