14
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

さくらVPSにgit共有リポジトリを構築する。

Posted at

自分しか使わないけど、リモートリポジトリがほしい。

超参考:Gitリモートリポジトリの作り方

ユーザー作成~リポジトリ構築

$ sudo su - 
$ adduser git
$ mkdir /var/lib/git
$ chown git:root /var/lib/git
$ sudo su - git
$ mkdir /var/lib/git/[リポジトリ名].git
$ cd /var/lib/git/[リポジトリ名].git
$ git --bare init --shared
$ mkdir ~/.ssh
$ chmod 0700 ~/.ssh
$ touch ~/.ssh/authorized_keys
[公開鍵を登録しておく]
$ chmod 0600 ~/.ssh/authorized_keys

リモートリポジトリ設定

ほかのホストから・・・

vim ~/.ssh/config
Host git-host
    HostName    xxx.xxx.xxx.xxx
    Port        xx
    IdentityFile ~/.ssh/id_rsa
    User        git
# User を先ほど作成したgitにして、気軽につながるようにする。
git remote add origin ssh://<config定義したホスト名:git-host>/var/lib/git/nouka.git
git push origin master

できた。

14
15
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
14
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?