Git入門操作
3606 ワード
Gitの入門操作だけを学ぶのは簡単で、普段はGit Hubをもっと使いますが、今日は自分でサービス練習をしたいと思っています.いくつかの材料が協力して検証された後、いわゆるサービスは以前のsvnとは全く異なることに気づいた.プロセスの記録は次のとおりです.
LinuxServer側インストールgit
私はサービスをLinuxマシンに打って、この破れたマシンはapt-getがなくて、yumがなくて、自分でソースコードをダウンロードして、自分でコンパイルするしかありません
順調でした:
Serverエンドssh構成
1)クライアント側がssh rsa公開鍵を作成していない場合は、まず次のように作成します.
2)クライアント側が作成する、~/.ssh/id_rsa.pubは、サーバ側にコピーします.
3)サーバ側のsshd_の変更config:
テストが有効かどうか
1)サーバ側に空のrepositoryを作成する
2)Client側でrepositoryを作成し、push
3)Client側cloneで作成したばかりのrepository
コミットしたばかりのコードツリーがcloneされていることを発見し、構築に成功したことを示します.
gitは分散型で主従の区別がないため、gitサービスを構築するということは、実は「サーバ」上のgitファイルにアクセスする権限を確保することであることを理解しています.これは、ファイルがリモートであるかローカルであるかとは関係ありません.たとえば、上記の例では、サーバをローカルに置くと、同じようにできます.
サーバがローカルに構築されていることを確認
1)ローカルに空のrepositoryを作成する
2)repositoryをローカルに作成してpushする
3)ローカルcloneで作成したばかりのrepository
レビュー~/localrepo 2は、やはりREADMEがクローンされています.
参考資料:
http://www.cnblogs.com/eileenleung/p/3503337.html
LinuxServer側インストールgit
私はサービスをLinuxマシンに打って、この破れたマシンはapt-getがなくて、yumがなくて、自分でソースコードをダウンロードして、自分でコンパイルするしかありません
$ wget http://distfiles.macports.org/git/git-2.5.3.tar.gz
$ tar xzvf git-latest.tar.gz
$ cd git-{date}
$ autoconf
$ ./configure --with-curl=/usr/local
$ make
$ make install
順調でした:
$ git --version
git version 2.5.3
Serverエンドssh構成
1)クライアント側がssh rsa公開鍵を作成していない場合は、まず次のように作成します.
$ cd ~
$ ssh-keygen -t rsa # ~/.ssh/id_rsa.pub
2)クライアント側が作成する、~/.ssh/id_rsa.pubは、サーバ側にコピーします.
$ ssh <username>@<server_ip>:.ssh/authorized_keys
id_rsa.pub 100% 416 0.4KB/s 00:00
3)サーバ側のsshd_の変更config:
$ ssh <username>@<server_ip>
$ cd /etc # /etc/ssh
$ sudo chmod 666 sshd_config
$ vi sshd_config
#PermitRootLogin yes PermitRootLogin no
# #
#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
#PasswordAuthentication no
#PermitEmptyPasswords no
#UsePAM yes UsePAM no
テストが有効かどうか
1)サーバ側に空のrepositoryを作成する
$ cd repo
$ git init -—bare # -—bare flag pushes, repository 。
2)Client側でrepositoryを作成し、push
$ mkdir localrepo
$ cd localrepo
$ git init
$ touch README
$ git add .
$ git commit -m “add README”
$ git remote add origin <username>@<server_ip>:/repo
$ git push origin master
3)Client側cloneで作成したばかりのrepository
$ git clone <username>@<server_ip>:/repo localrepo2
コミットしたばかりのコードツリーがcloneされていることを発見し、構築に成功したことを示します.
gitは分散型で主従の区別がないため、gitサービスを構築するということは、実は「サーバ」上のgitファイルにアクセスする権限を確保することであることを理解しています.これは、ファイルがリモートであるかローカルであるかとは関係ありません.たとえば、上記の例では、サーバをローカルに置くと、同じようにできます.
サーバがローカルに構築されていることを確認
1)ローカルに空のrepositoryを作成する
$ mkdir ~/repo
$ cd ~/repo
$ git init —bare
2)repositoryをローカルに作成してpushする
$ mkdir ~/localrepo
$ cd ~/localrepo
$ git init
$ touch README
$ git add .
$ git commit -m “add README”
$ git remote add origin ~/repo
$ git push origin master
3)ローカルcloneで作成したばかりのrepository
$ git clone ~/repo ~/localrepo2
レビュー~/localrepo 2は、やはりREADMEがクローンされています.
参考資料:
http://www.cnblogs.com/eileenleung/p/3503337.html