LoginSignup
41
39

More than 5 years have passed since last update.

Ubuntu上にgitサーバの構築

Posted at

サーバ側

まず、git, git-daemon, sysv-rc-confをinstall

$ sudo apt-get install git
$ sudo apt-get install git-daemon-sysvinit
$ sudo apt-get install sysv-rc-conf

起動有無の確認

$ sysv-rc-conf --list |grep git
git-daemon 0:off 1:off 2:on 3:on 4:on 5:on 6:off

gitリポジトリのディレクトリを変更するなら

/etc/default/git-daemon

の設定ファイルを変更

git-daemonの起動

$ /etc/init.d/git-daemon start

後はレポジトリを作ってclone出来るかの確認

ここで、clone出来るはずだけどconnection refusedに引っかかっていたのでsshでpath指定してcloneしたら出来た。

sshで入ったところにgitリポジトリを作り直して

$ mkdir project.git
$ cd project.git
$ git --bare init --shared

クライアント側

クライアント側でgitの初期設定(リモートブランチの設定等)

$ mkdir project
$ cd project
$ git init
$ echo "git test" > readme
$ git commit -am "first commit"
$ git remote add origin ssh://Host名/path/***.git
$ git push origin master

※remoteをタイポしてしまったときには

$ git remote set-url origin ssh://Host名***

で変更できる。

clone

$ git clone ssh://Host名/path/***.git

参考ページ

Gitリモートリポジトリの作り方
gitプロトコルでアクセスできるgitサーバをUbuntu上に構築する

41
39
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
41
39