ログイン
編集不可のページディスカッション情報添付ファイル
ytoku/memo/git

MMA

・特定のコミットのファイルにアクセス
  $ git show commit:path/to/file

・addすると何が起きるか
  working treeからcacheにコピーされる
・git diffの挙動はどうなっているのか
  http://www8.atwiki.jp/git_jp/pub/git-manual-jp/Documentation/chunked/ch03s03.html
  | $ git diff --cached # HEAD と索引間の差分;
  |                     # つまり、"commit" を実行したときにコミットされる内容
  | $ git diff          # 索引と作業ディレクトリ間の差分;
  |                     # つまり、"commit" を実行したときに含まれない
  |                     # 変更内容
  | $ git diff HEAD     # HEAD と作業ツリー間の差分:
  |                     # つまり、"commit -a" を実行したときにコミットされる内容
  | $ git status        # 上記のサマリをファイル毎に簡潔に表示

・作業内容を一時退避
  $ git stash save ["message"]
  do something...
  $ git stash apply

・git-cvsserver
  http://www.kernel.org/pub/software/scm/git/docs/git-cvsserver.html
  ・SSH
    .git/configに
    | [gitcvs]
    |    enabled=1
    または
    | [gitcvs "ext"]
    |    enabled=1
    を追加。
    $ export CVS_SERVER="git cvsserver"
    $ export CVSROOT=:ext:user@host/path/to/repos/.git
    $ cvs co -d dir branch(master)
  ・ローカルでSSHなし
    CVS_RSHを弄ってやればよいが、直接ではgit-cvsserverに渡される引数の関係でうまく動かない。
    -> 引数はディレクトリ制限として解釈される
    ローカルアクセス用のダミーを書いてやれば良さそう。
--- localsh ---
#!/bin/bash
if [ "$1" != "localhost" ]; then
  echo 'Usage: localsh "localhost" command'
  exit
fi
shift
sh -c "$*"
---------------
    $ export CVS_RSH=localsh
    $ export CVS_SERVER="git cvsserver"
    $ export CVSROOT=:ext:localhost:~/workspace/dev/project-euler/.git
    $ cvs co -d project-euler master
    ・! Index already exists in git repo
      http://lists-archives.org/git/658052-still-have-problem-with-index-file.html
      | git-cvsserver has always expected to serve up a "bare" repository
      サーバは作業コピーを伴っていてはいけないらしい。

・git-cvsimport
  ・! Branch 'origin' does not exist.

・過去のコミットを書き換えたい
  http://www8.atwiki.jp/git_jp/pub/Documentation.ja/user-manual.html#rewriting-one-commit
  rebase と commit --amend
・過去のコミットのAuthorをまとめて書き換えたい
  http://d.hatena.ne.jp/nobeans/20091008/1254965488
  rebase -i, commit --amend --author=NAME, rebase --continue
  rebase -iの時にs/^pick/edit/gする。

・gitkでマルチバイト文字が表示されない
  日本語のxfonts-*パッケージを入れてフォントの設定。
  ・xfonts-mplus: goth_pなど
  ・xfonts-intl-japanese: 

・git logを簡略な型式で見たい
  $ git log --abbrev-commit --pretty=oneline

・untracked fileを削除したい
  $ git clean -d -n (dry run)
  $ git clean -d -f
  -dがディレクトリも削除
  -nがdry run, -fで削除実行

・ベアリポジトリとはsuffixが.gitのリポジトリで、ワーキングエリアを持たないリポジトリ
・ベアリポジトリを作るには
  http://d.hatena.ne.jp/ntaku/20090418/1239981484
  ベアリポジトリ側を作り、普通のリポジトリを作ってremoteリポジトリとして追加、pushする。
  $ mkdir barerepo.git; cd barerepo.git
  $ git --bare init

  $ mkdir localrepo; cd localrepo
  $ git remote add origin /path/to/barerepo.git
  $ git add somthing
  $ git push origin master

・複数人で同じディレクトリのリポジトリを使うと、パーミッションが残念なことになる
  sharedオプションでumaskを強制
  http://d.hatena.ne.jp/hirose31/20090325/1237984133
  $ git init --shared=group
  あるいは
  [core]
    sharedRepository = group

[References]
Git - SVN Crash Course(in Japanese)
http://www.tempus.org/n-miyo/git-course-trans-ja/svn.ja.html

Git ユーザマニュアル (日本語訳)
http://www8.atwiki.jp/git_jp/pub/Documentation.ja/user-manual.html

Git User's Manual
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html

Git入門 (Wiki)
http://www8.atwiki.jp/git_jp/

ytoku/memo/git (最終更新日時 2011-01-25 23:50:37 更新者 ytoku)