wiki:TipAndDoc/scm/git

Version 34 (modified by mitty, 11 years ago) (diff)

--

Git

git via https

  • どぶお/開発しよう!/Gitクックブック - BioKids Wiki

    GitHubにHTTPSでアクセスするとSSL証明書の検証に失敗する

    この場合のように新たな証明書をOpenSSLへインストールする方法について解説したページが見つからなかったのでメモしておきます。

    1. git config --global http.sslCAPath "C:\Program Files (x86)\Git\ssl\certs"
      [http]
      	sslCAPath = C:\\Program Files (x86)\\Git\\ssl\\certs
      
      • 手動で追加する場合、以下のように書いてもよい
        [http]
        	sslCAPath = 'C:/Program Files (x86)/Git/ssl/certs'
        
    2. 証明書の用意
      • $ openssl x509 -inform der -in cacert.cer -out cacert.pem
      • $ mv cacert.pem openssl x509 -hash -noout -in cacert.pem.0
      • $ ls -l
        total 8671524
        -rw-r--r--  1 mitty mitty       1326 Jun  8 02:47 5391e9e0.0
        -rw-------  1 mitty mitty        937 Feb 19 10:08 cacert.cer
        
    3. C:\Program Files (x86)\Git\ssl\certs にコピー
    • うまくいかない
      • root証明書ではなくサーバ証明書も追加してみたがだめ
      • C:\Program Files (x86)\Git\bin\curl-ca-bundle.crt にBase64形式(この場合上記5391e9e0.0の中身)で追記する方法でもだめ
        • この方法では問題なく独自root証明書が使える
    • いずれも、Unknown SSL protocol error in connection to ... となる
      • SSL通信で使用できるプロトコルを制限したため、接続に失敗していた模様 (see also wiki:TipAndDoc/ssl#howtosecure)
      • SSL certificate problem: unable to get local issuer certificateとなる
      • git config --system --unset http.sslCAinfo としてもNG
        • UACのために、C:\Program Files (x86)\Git\etc\gitconfigではなく%LOCALAPPDATA%\VirtualStore\Program Files (x86)\Git\etc\gitconfigに書き込まれる点に注意

git-svn

convert svn repos to git

  • trunk/tags/branches -> -s オプションで拾える
  • vendor -> 手動でconfig --addしてfetch
  • リモートブランチをローカルブランチへ変更する
  1. mitty@test:~/works$ git svn init -s http://lab.mitty.jp/svn/lab/ lab
    Initialized empty Git repository in /home/mitty/works/lab/.git/
    
  2. mitty@test:~/works/lab (master)$ cat .git/config
    [core]
    	repositoryformatversion = 0
    	filemode = true
    	bare = false
    	logallrefupdates = true
    [svn-remote "svn"]
    	url = http://lab.mitty.jp/svn/lab
    	fetch = trunk:refs/remotes/trunk
    	branches = branches/*:refs/remotes/*
    	tags = tags/*:refs/remotes/tags/*
    
  3. mitty@test:~/works/lab (master)$ git config --add svn-remote.svn.fetch "vendor:refs/remotes/vendor"
    [core]
    	repositoryformatversion = 0
    	filemode = true
    	bare = false
    	logallrefupdates = true
    [svn-remote "svn"]
    	url = http://lab.mitty.jp/svn/lab
    	fetch = trunk:refs/remotes/trunk
    	branches = branches/*:refs/remotes/*
    	tags = tags/*:refs/remotes/tags/*
    	fetch = vendor:refs/remotes/vendor
    
  4. mitty@test:~/works/lab (master)$ git svn fetch
    Checked out HEAD:
      http://lab.mitty.jp/svn/lab/trunk r204
    creating empty directory: TipAndDoc/tools/trac/plugins
    
    • mitty@test:~/works/lab (master)$ ls -1F
      Commentary/
      Dev/
      misc/
      TipAndDoc/
      
    • mitty@test:~/works/lab (master)$ git tag -l
    • mitty@test:~/works/lab (master)$ git br -a
      * master
        remotes/tags/r89-trunk
        remotes/tags/snuploader_name
        remotes/tags/snuploader_name@29
        remotes/tags/snuploader_name@36
        remotes/tags/twitter
        remotes/trunk
        remotes/twitter-0.1
        remotes/twitter-0.1@44
        remotes/twitter-0.1@65
        remotes/twitter-0.1@66
        remotes/vendor
      
  5. mitty@test:~/works/lab (master)$ mv .git/refs/remotes/tags/* .git/refs/tags/
  6. mitty@test:~/works/lab (master)$ rmdir .git/refs/remotes/tags/
  7. mitty@test:~/works/lab (master)$ mv .git/refs/remotes/* .git/refs/heads/
  8. mitty@test:~/works/lab (master)$ rmdir .git/refs/remotes/
  9. vim .git/packed-refs
    :%s/refs\/remotes\/tags/refs\/tags/g
    :%s/refs\/remotes/refs\/heads/g
    
    • リポジトリがある程度以上の大きさの場合、必要になる
    • .git/packed-refs が存在しない場合はskipしてよい模様
  • mitty@test:~/works/lab (master)$ git tag -l
    r89-trunk
    snuploader_name
    snuploader_name@29
    snuploader_name@36
    twitter
    
  • mitty@test:~/works/lab (master)$ git br -a
    * master
      trunk
      twitter-0.1
      twitter-0.1@44
      twitter-0.1@65
      twitter-0.1@66
      vendor
    
    • mitty@test:~/works/lab (master)$ git co vendor
      Switched to branch 'vendor'
      
    • mitty@test:~/works/lab (vendor)$ ls -1F
      DrRacket/
      GeSHi-1.0.8.9/
      lxc/
      OCaml/
      SnUploader/
      TipAndDoc/
      trac/
      twitter/
      ubuntu/
      utvpn/
      vmware/
      

git-http-backend

  • Ubuntu 12.04では、fcgiwrapパッケージを導入すると/var/run/fcgiwrap.socketが自動的に作成される

gitweb

  • 以下の様に設定するのがすっきりすると思われる
    	location /gitweb/ {
    		fastcgi_pass unix:/var/run/fcgiwrap.socket;
    		fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi;
    		include fastcgi_params;
    	}
    
    • /gitweb/(.*)/gitweb(/.*)とすると、リンクが正常に生成されないので注意

prompt

  • bash

github