2010-11-12
$ sudo port install git-core
db46 を入れようとしている。mercurial と同じように失敗しそうだ。。
macports の手順で db46 を入れたら成功した。
$ which git /opt/local/bin/git
since 2011-07-21
Lion ではなく Snow Leopard で作業をする。
ダウンロード したのは、 git-1.7.6-x86_64-snow-leopard.dmg である。
ダブルクリックしてインストール。
"setup git PATH for ….sh" というファイルも(ターミナルから)実行しておいた。
ログオフして再度ログオンし直す。
$ which git /usr/local/git/bin/git $ git --version git version 1.7.6
$ git config --global user.name "Your Name" $ git config --global user.email you@example.com
好みでページャーの設定
[.bashrc]
export GIT_PAGER=lv
自分の名前やアドレスの設定をしないで commit してしまっても、直後に修正ができる。
$ git commit --amend --author='Takuya Nishimoto <nishimotz@gmail.com>'
ファイル本体に変更はなくても msys から見た場合のファイルモード(パーミッション)が違っていて、git がそれを「変更あり」と検知している可能性を回避する
git config core.filemode false
git init して最初の git add をする前に。。
$ echo "_*" >> .gitignore $ echo "*~" >> .gitignore $ echo "CVS" >> .gitignore
_ではじまるファイル名を一時ファイルにする、というのは個人的な流儀。詳細は下記:
mv してから git add / git rm するより git mv したほうがよさそう。
$ git mv old_name new_name
まとめて登録
$ git add -f .
管理したくないファイルを削除する
$ git rm --cached -r log/*
カレントディレクトリに git-test ディレクトリを作成し、そこに .git を作り、 master ブランチの checkout まで行う。
$ git clone ssh://remote-machine/home/username/git-test Initialized empty Git repository in /home/username/git-test/.git/ The authenticity of host '***' can't be established. RSA key fingerprint is *****. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '***' (RSA) to the list of known hosts. username@remote-machine's password: (((pw))) remote: Counting objects: 7, done. remote: Compressing objects: 100% (4/4), done. remote: Total 7 (delta 0), reused 0 (delta 0) Receiving objects: 100% (7/7), done. $ ls git-test hoge.c hoge.h
git remote origin は git clone すれば設定済み??
$ git remote add origin ssh://xxxx/zzz remote origin already exists. $ git remote origin
$ git remote -h
Usage: git remote
git remote add <name> <url>
git remote rm <name>
git remote show <name>
git remote prune <name>
git remote update [group]
$ git remote show
Usage: git remote show <remote>
$ git remote show origin
username@remote-machine's password:
* remote origin
URL: ssh://remote-machine/home/username/git-test
Remote branch(es) merged with 'git pull' while on branch stable
stable
Tracked remote branches
master stable
local-machine で修正を加えて git commit, git push する。
push された変更を remote-machine で checkout したい。
$ git checkout M rails/config/environment.rb M rails/log/development.log 反映されない $ git checkout -f やっと反映される
git commit しようとすると
fatal: cannot do a partial commit during a merge.
git merge しようとすると
xxxx.rb: needs merge
git add xxxx.rb すれば git commit できる。