0
1

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.

gitの設定 (ssh認証失敗, gitweb, ...)

Last updated at Posted at 2016-11-19

git serverの構築 (remote repository)

これで ssh://git@xxx/opt/git/xxxx.git でアクセスできるようになる.

  • git:// を有効にするためには git daemon
  • http:// を有効にするためには smart HTTP

gitwebをインストール

(参考)【Ubuntu 16.04 LTS Server】gitwebを使う

  • /etc/gitweb.conf を修正
    $projectroot="/opt/git"
  • apacheにgitへのアクセス権付与
    sudo gpasswd -a www-data git
  • apachにgitwebの設定を追加
$ vi /etc/apache2/conf-available/gitweb.conf
$ a2enconf gitweb

gitwebは、/usr/lib/cgi-bin/gitweb のCGIを実行している
(実体は、/usr/lib/share/gitweb/ にある)

windows側でgitをセットアップ

  • msysgitをinstall

  • TortoiseGitをinstall

  • TortoiseGit の ssh clientをmsysgitのものに変更する(putty不要)

    • Settings -> Network -> SSH client = c:\devel\git\usr\bin\ssh.exe
  • msysgitのgit bashを立ち上げて鍵を作成
    $ ssh-keygen.exe -t rsa -C "user@hostname"

  • ~/.ssh/id_rsa.pub の内容を,git server の /home/git/.ssh/authorized_keys に追加する

  • git clone ssh://git@hostname/opt/git/xxxxx.git

git の branch model の確認

(参考) ぼくが実際に運用していたGitブランチモデルについて
https://havelog.ayumusato.com/develop/git/e513-git_branch_model.html

  • master : 完全に動作するとき入れる
  • develop : とりあえず適当に入れる
  1. local側にdevelop branchを作成する
  2. develop branchにswitchして,ローカルで作業
  3. push 時に remote のbranchにdevelopを指定してpushすると,remote側にbranchがそのままできる.

※うまく作れたらcloneしなおしたほうが良いかも

web serverへのdeployの自動化

(参考) gitでシンプルなデプロイ環境を作る

server側でclone

$ cd /var/www
$ git clone /opt/git/xxxx.git
$ git pull origin develop

hook/post-receiveを作成. chown git:git, chmod a+x

xxxx.git/hooks/post-receive
# !/bin/sh
cd /var/www/xxxx
git --git-dir=.git pull origin develop
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?