#author("2018-04-20T18:36:19+09:00","default:Miyashita","Miyashita")
#author("2018-07-26T00:49:24+09:00","default:Miyashita","Miyashita")
*共有リポジトリの作成 [#xa5a0e8b]
既存のローカルリポジトリから,共有リポジトリを作成する方法について.~
**研究室等のサーバーに作成 [#j69d129c]
便宜上,パスを以下の(A),(B)のように定義しておく.~
(A)作成する共有リポジトリのパス(サーバー上など)~
(B)ローカルリポジトリのパス(原則的に外部接続でない自分のPC)~
+(A)に空の共有リポジトリを作成~
(A)の場所で,例えばsharedrepという名前のディレクトリを作成する.~
これが共有リポジトリのベースとなる.~
ついでに権限を変更しておく.
 mkdir sharedrep
 chmod a+wx sharedrep
#codeprettify{{
mkdir sharedrep
chmod a+wx sharedrep
}}
~
+(A)で共有リポジトリの設定,初期化~
移動して,リポジトリを初期化する.
 cd sharedrep
 git init --bare --shared
#codeprettify{{
cd sharedrep
git init --bare --shared
}}
共有リポジトリではinitの次にこのオプションをつけるものと思っておけば良い,気がする.~
lsとすると"branches"やら"info"やらのディレクトリがあることが確認できる.~
~
+(B)のローカルリポジトリを(A)へpush~
ローカルリポジトリから,共有リポジトリ(A)のリモート名(この場合はorigin)をつけて,pathを定義する.
 git remote add origin miyashita@xxx.xxx.xxx.xxx:~~~/sharedrep
#codeprettify{{
git remote add origin miyashita@xxx.xxx.xxx.xxx:~~~/sharedrep
}}
その後,作成した(A),すなわちoriginへ情報を送りつける.
 git push origin "*"
#codeprettify{{
git push origin "*"
}}
"*"のつけ忘れに注意.~
これでローカルと同じ内容のものがshredrepに作成され,共有リポジトリとなった.~
また,(A)(B)と別の場所にローカルリポジトリを作成したい場合,
 git clone miyashita@xxx.xxx.xxx.xxx:~~~/sharedrep
#codeprettify{{
git clone miyashita@xxx.xxx.xxx.xxx:~~~/sharedrep
}}
で持ってくることができる.

**Bitbucket,GitHubに作成 [#ndbaef04]
学外ネットワークからでも最新の情報を引き抜きたい場合は,無料で非公開の共有リポジトリが作成できる[[Bitbucket>https://bitbucket.org/]]等を使う.学生ならGitHubでも無料で非公開のリポジトリが作成可能.~
空のリポジトリを作成後,ローカルリポジトリから
 git remote add origin https://username@bitbucket.org/username/repositoryname.git
 git push -u origin master
#codeprettify{{
git remote add origin https://username@bitbucket.org/username/repositoryname.git
git push -u origin master
}}
で送信する.originやmasterの部分は都合に応じて適切な名前をつける.~

Front page   Edit Diff Attach Copy Rename Reload   New List of pages Search Recent changes   Help   RSS of recent changes