[[PageOutline]] = Git = * [http://git-scm.com/book/ja/ Git - Book] * [http://git-scm.com/book/ja/Git-%E3%81%AE%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E6%A9%9F%E8%83%BD-%E3%83%96%E3%83%A9%E3%83%B3%E3%83%81%E3%81%AE%E7%AE%A1%E7%90%86 3.3 Git のブランチ機能 - ブランチの管理] > 現在作業中のブランチにマージ済みのブランチを調べるには git branch –merged を実行します。 > まだマージされていない作業を持っているすべてのブランチを知るには、git branch --no-merged を実行します。 * [http://www8.atwiki.jp/git_jp/ Git入門 - トップページ] * [http://www.hyuki.com/techinfo/gitinit.html Gitの基礎練習] * [http://www.machu.jp/diary/20100506.html#p01 Subversion ユーザーが Git を使ってみた (基本操作編) - まちゅダイアリー(2010-05-06)] * Subversion使っている人間としては分かりやすい * [http://d.hatena.ne.jp/propella/20110105/p1 ファイルシステムとしての Git - 言語ゲーム] * twitter:suma90h/status/23299114481491968 * [http://d.hatena.ne.jp/idesaku/20091230/1262159267 git-cherry-pickを掘り下げる - idesaku blog] * twitter:random_oracle/status/24024533967044608 * [http://d.hatena.ne.jp/murank/20110320/1300619118 git diff の使い方がほんの少し理解できた - murankの日記] * [http://d.hatena.ne.jp/murank/20110327/1301224770 git reset についてもまとめてみる - murankの日記] * 図入りで説明 * [http://transitive.info/article/git/info/concept/ transitive.info - Git 考え方] > * キャレットとチルダ * {{{HEAD^}}}と{{{HEAD~}}}の違いなど * [http://d.hatena.ne.jp/kk_Ataka/20120410/1334058674 Pro Gitと入門Gitと入門gitでGitの復習 HEADのキャレットとかチルダとか補講編 - kk_Atakaの日記] * こちらも分かりやすい * [http://d.hatena.ne.jp/hokaccha/20120404/1333507076 git pullの詳細な挙動を追ってみる - hokaccha.hamalog v2] * [http://dqn.sakusakutto.jp/2012/11/git_pull.html Git pullを使うべきでない3つの理由 - DQNEO起業日記] * [http://d.hatena.ne.jp/kitokitoki/20121031/p1 git fetch と git pull と git remote update の違い - わからん] * [http://stackoverflow.com/questions/2688251/what-is-the-difference-between-git-fetch-origin-and-git-remote-update-origin What is the difference between `git fetch origin` and `git remote update origin`? - Stack Overflow] > The answer recommending {{{remote update}}} instead of git fetch was actually recommending it without a remote name, just for the sake of fetching all, not just the one named as an argument. This is equivalent to {{{git fetch --all}}}. * [http://stackoverflow.com/questions/3959924/whats-the-difference-between-git-clone-mirror-and-git-clone-bare What's the difference between git clone --mirror and git clone --bare - Stack Overflow] * 通常のclone, clone --bare, clone --mirrorの違いについて詳しく書かれている * [http://d.hatena.ne.jp/shim0mura/20120914/1347591103 gitのbareリポジトリのバックアップをとる - 馬鹿と天才は紙一重] > バックアップ用のリポジトリを作るのであれば--bareではなく--mirrorというオプションをつけます。 > {{{ > $ git clone --mirror yamucha chaoz > }}} > git-pullをすると、chaozはbareリポジトリだから管理ファイルしか存在しないためにmergeができないよと怒られます。なのでここではgit-fetchをしないといけません。 * [http://d.hatena.ne.jp/tyru/20110723/git_clone_mirror git clone --mirror - Humanity] > --mirrorは実際これと同じことをしてるっぽい(たぶん) > {{{ > $ git clone --bare {uri} > $ cd {dir} > $ git config remote.origin.fetch '+refs/*:refs/*' > $ git config remote.origin.url $uri > $ git config remote.origin.mirror true > }}} * [https://help.github.com/articles/duplicating-a-repository Duplicating a repository · GitHub Help] > {{{ > $ git clone --bare https://github.com/exampleuser/old-repo.git > $ cd old-repo.git > $ git push --mirror https://github.com/exampleuser/new-repo.git > }}} * [http://dqn.sakusakutto.jp/2012/11/git_export_archive_checkout_index.html Gitでexportするときはgit archiveとgit checkout-indexのどちらがよいか - DQNEO起業日記] > masterブランチをエクスポートしたいとします。 > {{{#!bash > mkdir /tmp/foo > git archive master | tar -x -C /tmp/foo > }}} > (必ず先に空のディレクトリを作っておきましょう。) * [http://wiki.livedoor.jp/deya4791/d/gitolite%20%A4%C8%20cgit gitolite と cgit - ひるね - Seesaa Wiki(ウィキ)] * [https://joel.porquet.org/wiki/hacking/cgit_gitolite_lighttpd_archlinux/ How to make cgit play well with gitolite] * {{{Error: Missing language pack for 'Adobe-Japan1' mapping}}}などのエラーが大量に出る * C:\Program Files (x86)\Git\bin\astextplain で使われている{{{pdftotext}}}がエラーの元 * [http://homepage3.nifty.com/iranoan/essay/pc/200809210.htm Google デスクトップで検索できない<-コンピュータ<-徒然なるままに<-Iranoan] に従って、適当な場所にpdftotextをインストール * {{{C:\Program Files (x86)\Git\bin\pdftotext.exe}}}を削除orリネーム * [http://stackoverflow.com/questions/13500294/merge-a-branch-into-a-new-sub-directory-on-the-master git - merge a branch into a new sub directory on the master - Stack Overflow] * ex) {{{git am -p2 --directory=production/ test/*.patch}}} * {{{-p}}}、{{{--directory=}}}はいずれもgit applyのオプション * -pのデフォルトは-p1 = rewrite history= * [http://git-scm.com/book/ja/v2/Git-%E3%81%AE%E3%81%95%E3%81%BE%E3%81%96%E3%81%BE%E3%81%AA%E3%83%84%E3%83%BC%E3%83%AB-%E6%AD%B4%E5%8F%B2%E3%81%AE%E6%9B%B8%E3%81%8D%E6%8F%9B%E3%81%88 Git - 歴史の書き換え] * [http://easyramble.com/git-filter-branch.html Git の履歴からファイルを完全に削除する – git filter-branch | EasyRamble] * [http://ariya.ofilabs.com/2014/07/extracting-parts-of-git-repository-and-keeping-the-history.html Extracting Parts of Git Repository and Keeping the History] * [http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository git subtree - Detach subdirectory into separate Git repository - Stack Overflow] * [http://stackoverflow.com/questions/5324799/git-remove-commits-with-empty-changeset-using-filter-branch Git - remove commits with empty changeset using filter-branch - Stack Overflow] * [http://space-on-my-hands.blogspot.jp/2014/05/gitsubtree-merge.html 宇宙をぼくの手の上に: Gitでsubtree mergeによるライブラリ管理] * [http://stackoverflow.com/questions/3142419/how-can-i-move-a-directory-in-a-git-repo-for-all-commits git filter branch - How can I move a directory in a Git repo for all commits? - Stack Overflow] = git via https = * [http://biokids.org/?%A4%C9%A4%D6%A4%AA%2F%B3%AB%C8%AF%A4%B7%A4%E8%A4%A6%A1%AA%2FGit%A5%AF%A5%C3%A5%AF%A5%D6%A5%C3%A5%AF どぶお/開発しよう!/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}}}に書き込まれる点に注意 * [http://stackoverflow.com/questions/3777075/ssl-certificate-rejected-trying-to-access-github-over-https-behind-firewall git - SSL certificate rejected trying to access GitHub over HTTPS behind firewall - Stack Overflow] > {{{ > $ env GIT_SSL_NO_VERIFY=true git clone https://github... > }}} = git-svn = * [http://stackoverflow.com/questions/8333870/is-there-an-advantage-to-using-no-metadata-in-git-svn-clone Is there an advantage to using --no-metadata in git svn clone? - Stack Overflow] > This option is NOT recommended as it makes it difficult to track down old references to SVN revision numbers in existing documentation, bug reports and archives. * [http://blog.s21g.com/articles/618 git-svnでSVN上の複数のブランチやtrunkを扱う方法 - Hello, world! - s21g] * [http://stackoverflow.com/questions/1584675/converting-svn-to-git-how-to-get-the-branches-not-to-be-just-remote-in-the-svn Converting svn to git, how to get the branches not to be just remote in the svn repo? - Stack Overflow] == 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/ }}} 1. 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/* }}} 1. 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 }}} 1. 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 }}} 1. mitty@test:~/works/lab (master)$ mv .git/refs/remotes/tags/* .git/refs/tags/ 1. mitty@test:~/works/lab (master)$ rmdir .git/refs/remotes/tags/ 1. mitty@test:~/works/lab (master)$ mv .git/refs/remotes/* .git/refs/heads/ 1. mitty@test:~/works/lab (master)$ rmdir .git/refs/remotes/ 1. 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 = * [https://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html git-http-backend(1)] * [http://d.hatena.ne.jp/ono51/20120619/p1 nginxでgitリポジトリの公開 - Smart HTTPを試してみた - 逆襲のWebエンジニア] * [http://www.toofishes.net/blog/git-smart-http-transport-nginx/ toofishes.net - Git smart HTTP transport on nginx] * [http://serverfault.com/questions/334127/howto-nginx-git-http-backend-fcgiwrap-debian-squeeze Howto Nginx + git-http-backend + fcgiwrap (Debian Squeeze) - Server Fault] * fastcgi_passは最初の方にあっても良い模様 * {{{fastcgi_param SCRIPT_FILENAME}}}はかならず{{{include fastcgi_params}}}よりも先に記述しないとダメ(以下の様に意図しない場所へchdirされエラーになる) {{{ FastCGI sent in stderr: "Cannot chdir to script directory (/usr/share/nginx/www/git/test.git/info)" }}} * Ubuntu 12.04では、{{{fcgiwrap}}}パッケージを導入すると{{{/var/run/fcgiwrap.socket}}}が自動的に作成される * [http://stackoverflow.com/questions/7222992/git-http-backend apache - git-http-backend - Stack Overflow] * [http://serverfault.com/questions/497051/git-http-backend-ro-for-all-write-requiring-password-with-lighttpd trac - git-http-backend, ro for all, write requiring password? (with lighttpd) - Server Fault] * [http://git.661346.n2.nabble.com/git-http-backend-anonymous-read-authenticated-write-td7582095.html git - git-http-backend: anonymous read, authenticated write] > the man-page is wrong = gitweb = * [https://www.kernel.org/pub/software/scm/git/docs/gitweb.conf.html gitweb.conf(5)] * github:kogakure/gitweb-theme * [https://sixohthree.com/1402/running-gitweb-in-fastcgi-mode Running gitweb in FastCGI Mode | 603] * [http://serverfault.com/questions/72732/how-to-set-up-gitweb apache2 - How to set up Gitweb - Server Fault] * [http://d.hatena.ne.jp/wait-st/20111016/1318755726 gitweb + Nginx を使ってgitリポジトリをWEBで見られるようにする - Wait at a Street corner] * [http://d.hatena.ne.jp/Yudoufu/20110626/1309066814 gitoliteとgitweb on nginx を連携させたメモ - ゆどうふろぐ] * [https://gist.github.com/beheadedmyway/1549832 Gitweb on Centos behind Nginx with init script.] * [http://rouge.eu.org/blog/web/git-web-nginx/ Using git-web with nginx | Jeff's musings] * 以下の様に設定するのがすっきりすると思われる {{{ location /gitweb/ { fastcgi_pass unix:/var/run/fcgiwrap.socket; fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi; include fastcgi_params; } }}} * ~~{{{/gitweb/(.*)}}}を{{{/gitweb(/.*)}}}とすると、リンクが正常に生成されないので注意~~ = gitweb and git-http-backend on same url = * [https://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html git-http-backend(1)] > This can be combined with the gitweb configuration: > {{{ > SetEnv GIT_PROJECT_ROOT /var/www/git > > AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/www/git/$1 > AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1 > ScriptAliasMatch \ > "(?x)^/git/(.*/(HEAD | \ > info/refs | \ > objects/info/[^/]+ | \ > git-(upload|receive)-pack))$" \ > /usr/libexec/git-core/git-http-backend/$1 > ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/ > }}} * [http://tikalk.com/alm/setup-git-gitweb-git-http-backend-smart-http-ubuntu-1204 Setup Git, Gitweb with git-http-backend / smart http on ubuntu 12.04 | Tikal] * fcgiをインストールしているが、実際には使われていないように読める * [http://paperlined.org/apps/git/SmartHTTP_Ubuntu.html paperlined.org/apps/git/SmartHTTP_Ubuntu.html] * gitweb + git-http-backend + git push with Basic Authentication * このサイトでは{{{RewriteRule (.*) $1 [E=AUTHREQUIRED:yes]}}}としているが、これではQUERY_STRINGが落ちてしまいうまく動かない * [http://peter.stuge.se/nginx-git-http-backend-and-gitweb-on-same-url Stuge says.. :: Making nginx serve git-http-backend and gitweb on the same URL] * [http://weininger.net/configuration-of-nginx-for-gitweb-and-git-http-backend/ NGINX Configuration for Gitweb and git-http-backend - Weinimos World] * https://lab.mitty.jp/git/ で実際に用いている設定(Apache2) {{{ RewriteEngine On RewriteCond %{QUERY_STRING} =service=git-receive-pack [OR] RewriteCond %{REQUEST_URI} /git-receive-pack$ RewriteRule /git/ - [E=AUTHREQUIRED:yes] SetEnv GITWEB_CONFIG /etc/gitweb/lab.conf SetEnv GIT_HTTP_EXPORT_ALL SetEnv GIT_PROJECT_ROOT /path/to/projectroot/lab Order Deny,Allow Deny from env=AUTHREQUIRED AuthType Basic AuthName "Authentication for lab.mitty.jp" AuthUserFile /path/to/htpasswd.file Require valid-user Satisfy Any AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /path/to/projectroot/lab/$1 AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /path/to/projectroot/lab/$1 ScriptAliasMatch \ "(?x)^/git/(.*/(HEAD | \ info/refs | \ objects/info/[^/]+ | \ git-(upload|receive)-pack))$" \ /usr/lib/git-core/git-http-backend/$1 Alias /git /usr/share/gitweb Options +ExecCGI DirectoryIndex gitweb.cgi AddHandler cgi-script .cgi }}} * gitweb/git-http-backend を一つのURLでアクセス可能にしている * git fetchは認証なし、pushは要認証 * https://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html でLocationMatchを用いて説明されている方法は古いため動かない * man git-http-backend あるいは http://man7.org/linux/man-pages/man1/git-http-backend.1.html などにあるように、mod_rewriteが必要 * {{{Order Deny,Allow}}}、{{{Satisfy Any}}}などに注意 * /etc/gitweb/lab.conf {{{ $projectroot = "/var/git/lab"; @git_base_url_list = ($cgi->url(-base => 1) . '/git'); }}} * GITWEB_CONFIGでgitwebインスタンスごとに設定ファイルを指定できる * man git-http-backendではgitwebは{{{ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/}}}などとしているが、うまく動かない * {{{/git/?p=lab.git}}}となるべきリンクが{{{/git?p=lab.git}}}となってしまう * wiki:TipAndDoc/network/httpd#ScriptAlias にあるように、自身のURLが{{{/}}}で終わらない形になるためと思われる * Alias + Directoryで対応 = prompt = * bash * [http://blog.asial.co.jp/845 Gitを使い始めたらやっておきたい便利な設定いろいろ : アシアルブログ] * [http://d.hatena.ne.jp/deeeki/20110402/git_branch_ps1 Gitブランチ名を__git_ps1でbashプロンプトに表示 - 130単位] * [http://d.hatena.ne.jp/notogawa/20120720/1342756620 bashのプロンプトにブランチ名を右寄せ表示する - ぼくのぬまち 出張版] * source:lab/trunk/TipAndDoc/.gitconfig, source:lab/trunk/TipAndDoc/.bashrc = github = * [http://addyosmani.com/blog/backing-up-a-github-account/ Pro-tip: How To Backup All Of Your GitHub Repositories In One Go] * github:joeyh/github-backup * [http://daicham.hatenablog.com/entry/20111005/1317829785 初めてPull Requestをマージしてみた - daicham blog] * [http://akisute.com/2011/02/github-pull-request.html A-Liaison BLOG: github で pull request をされたとき・するときの手順] * [http://d.hatena.ne.jp/hnw/20110528 GitHubへpull requestする際のベストプラクティス - hnwの日記] > ここで大事な点を強調しておきますが、絶対にmasterブランチで作業してはいけません。また、masterブランチからpull requestを送るのもいけません。必ずpull requestのための別ブランチから送るようにしましょう。 * [http://stackoverflow.com/questions/10045517/embedding-images-inside-a-github-wiki-gollum-repository documentation - Embedding images inside a GitHub wiki (gollum) repository? - Stack Overflow] > github:mojombo/gollum-demo/blob/master/Mordor/Eye-Of-Sauron.md = GitLab = * [http://knowledge.sakura.ad.jp/tech/3005/ GitHubのようなサイトを独自に運用できる「GitLab」や「GitBucket」を使ってみよう - さくらのナレッジ]