Linux(CentOS)に「Git」をインストールし、「共有リポジトリ」を作成する。
そして、WindowsのローカルリポジトリからVMwareのCentOSの共有リポジトリへ「push」する。
pushするリポジトリはオープンソースオンライン家計簿の小槌。
小槌の詳細はこちらの記事参照⇒Ruby on Railsのオープンソース家計簿「小槌」のPostgreSQL対応
なお、今回のバージョンは以下です。
- CentOS-6.4-i386
Gitのインストール
下記コマンドで「Git」をインストールする。
1 2 3 4 5 6 | #Gitのインストール $ yum install git #Gitの確認 $ git --version git version 1.7.1 |
bareリポジトリの作成
下記コマンドでディレクトリを作成し、「bareリポジトリ」を作成する。
「bareリポジトリ」とは空っぽのといった感じらしく、サーバーで共有リポジトリとかにする場合、これにするらしい。
ディレクトリは、rootユーザーで作成後、ユーザー「myuser」、グループ「myuser」に所有者・グループ変更した。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #空ディレクトリ「/rep/rails」の作成 $ mkdir rep $ mkdir rep /rails #ディレクトリ移動 $ cd /rep/rails #リポジトリの作成 $ git init --bare --shared= true kozuchi #オーナーをユーザー「myuser」に変更 $ chown myuser -R /rep #グループをグループ「myuser」に変更 $ chgrp myuser -R /rep |
なお、リポジトリ作成後もbareリポジトリに変更することもできるよう。
1 2 3 4 5 6 7 8 9 10 11 12 13 | #リポジトリ作成 $ git init #bareリポジトリかどうか確認 $ git config --get-all core.bare false #bareリポジトリへ変更 $ git config --bool core.bare true #bareリポジトリかどうか確認 $ git config --get-all core.bare true |
WindowsのローカルリポジトリからVMwareのCentOSのbareリポジトリへpush
Windows上のリポジトリへ移動し、以下のコマンドでCentOSのbareリポジトリへpushする。
コマンドは「git push ユーザー名@ホスト名(もしくはIPアドレス):リポジトリのパス master」。
実際のコマンドは以下です。
1 2 3 4 5 6 7 8 9 10 11 | C:\> cd C:\Projects\rails\kozuchi C:\>git push myuser@192.168.190.128: /rep/rails/kozuchi master myuser@192.168.190.128's password: パスワード入力(非表示) Counting objects: 19499, done . Delta compression using up to 2 threads. Compressing objects: 100% (11916 /11916 ), done . Writing objects: 100% (19499 /19499 ), 14.34 MiB | 4.98 MiB /s , done . Total 19499 (delta 6776), reused 19417 (delta 6709) To myuser@192.168.190.128: /rep/rails/kozuchi * [new branch] master -> master |
なお、2で「bareリポジトリ」にしていないと以下のようなエラーになる。
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 | C:\>git push myuser@192.168.190.128: /rep/rails/kozuchi master myuser@192.168.190.128's password: パスワード入力(非表示) Counting objects: 19499, done . Delta compression using up to 2 threads. Compressing objects: 100% (11916 /11916 ), done . Writing objects: 100% (19499 /19499 ), 14.34 MiB | 7.90 MiB /s , done . Total 19499 (delta 6776), reused 19417 (delta 6709) remote: error: refusing to update checked out branch: refs /heads/master remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match remote: error: the work tree to HEAD. remote: error: remote: error: You can set 'receive.denyCurrentBranch' configuration variable to remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into remote: error: its current branch; however, this is not recommended unless you remote: error: arranged to update its work tree to match what you pushed in some remote: error: other way. remote: error: remote: error: To squelch this message and still keep the default behaviour, set remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse' . To myuser@192.168.190.128: /rep/rails/kozuchi ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to 'myuser@192.168.190.128:/rep/rails/kozuchi' |
以上で終了ー。
参考サイト
gitエラー「refusing to update checked out branch」の回避法 – karasuyamatenguの日記
コメント
[…] [zigutabi] ここの説明でよくわからない点がありました。 [zigutabi] http://itmemo.net-luck.com/linux-centos-git-install/ [zigutabi] […]