以下、備忘録として、さくらレンタルサーバーでの git のリモートリポジトリ作成について。
すでに、csh 環境から bash 環境に変更されていることを前提にしています。
参考サイトとほぼほぼ同じ手順ですが、さくらでの git のインストールは不必要でした。
また、ローカルの環境は cygwin 環境です。
リモート側のセットアップ
さくらでのリモートリポジトリを作成します。
--bare
で作業用ディレクトリ無しで初期化しています。
$ mkdir -p $HOME/git/repos.git $ cd $HOME/git/repos.git $ git init --bare Initialized empty Git repository in /home/example/git/repos.git/
クライアント側のセットアップ
クライアント側で適当にコミットしてみます。
まずは初期化。
ホームディレクトリ直下に、適当なフォルダ git を作成しています。
$ cd $HOME $ mkdir git $ cd git
次に、空のテキストファイルを作成して、コミット。
$ touch README $ git add README $ git commit -m "initial commit"
初めて使用する環境の場合、以下のようなエラーが発生するかもしれません。
指示されている通り、特定できるようにユーザー名やメールアドレスを設定すれば、問題なくコミットできるようになるはずです。
*** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got '***')
コミットが成功すれば、以下のようにリモートリポジトリを追加し、プッシュするだけです。
$ git remote add origin sakura:~/git/repos.git $ git push origin master
ここでは、すでに以下の config のようにホスト名を登録しています。
Host sakura HostName example.sakura.ne.jp User example IdentityFile ~/.ssh/id_rsa.sakura.ne.jp ServerAliveInterval 20 ServerAliveCountMax 3
未登録の場合には、以下のようにユーザー名やサーバー名の指定が必要になります。
$ git remote add origin example@example.sakura.ne.jp:~/git/repos.git $ git push origin master