LoginSignup
1
2

More than 3 years have passed since last update.

Gitのリポジトリを共有サーバーに作成する

Last updated at Posted at 2020-03-02

ローカルで作業しているけど変更管理は共有サーバーでしたい

共有サーバーにリモートブランチを作成してローカルで作業するときの手順。

共有サーバー側の作業

「.git」を末尾に付与したディレクトリを作成して、変更管理用の初期化を行います。
※このディレクトリではソースなど作業ファイルを格納して作業を行うわけではありません。

$ mkdir hogehoge.git
$ cd ./hogehoge.git
$ git init --bare --shared
$ git remote add <name> <url>
  • <name>: ブランチ名
  • <url>: 接続先(ローカルから接続できること)

例1; $ git remote add origin C:/git/hogehoge.git
例2; $ git remote add origin http://hogehoge.git

ローカル側の作業

$ mkdir hogehoge
$ cd hogehoge
$ git init
$ git commit --allow-empty -m "initial commit"
$ git remote add <name> <url>
$ git push <name> master

<name><url>はリモート側と同じ内容を入力すれば紐づけることができます。
別の環境で作業するときは作ったリモートリポジトリをcloneすれば作業を行えます。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2