By utahta, on 9月 28th, 2009%
構成
クライアント MacBook
サーバ Linux
作業ディレクトリ myproj
初期設定
名前とメールアドレスの設定。
$ git config --global user.name "hoge"
$ git config --global user.email "hoge@mail.com"
色の設定。
$ git config --global color.ui auto
リポジトリ作成
myproj ディレクトリをリポジトリ化する。
$ mkdir myproj
$ cd myproj
$ git init
リモートサーバに空のリポジトリつくる。
$ ssh remote-host
$ mkdir myproj
$ cd myproj
$ git init --bare
ファイル追加&コミット
ファイルを追加する。
$ vi a.txt
$ git add a.txt
$ git commit -m "add a.txt"
add 取り消し
間違って add したファイルを取り消す
$ vi b.txt
$ git add b.txt
$ git rm --cached b.txt
間違って add したディレクトリを再帰的に取り消す
$ mkidr src
$ cd src
$ vi c.cpp
$ cd ../
$ git add src
$ git rm --cached -r src
リモートにプッシュ&プル
リモートサーバに push, リモートサーバから pull する。
$ git remote add origin name@remote-host:myproj
$ git push origin master
$ git pull origin master
push, pull の default を設定
push, pull する default 宛先を設定する。
今回は、branch master → origin へ。
$ git config --add branch.master.remote origin
$ git config --add branch.master.merge master
このままだと push するとき waring が出るので、 config に適切な値を設定する。
$ git config --global push.default matching
参考:git config push.default matching
ファイル移動&リネーム
ファイルやディレクトリの移動、リネームをする。
大文字から小文字へといったリネームの際、失敗することがある模様。
以下、実際にエラーが出た例。
$ git mv LaunchDaemons/ launchdaemons/
fatal: renaming LaunchDaemons failed: Invalid argument
いったん、別名にしてあげれば対処可能。
なんか腑に落ちなくはあるけども。
$ git mv LaunchDaemons/ launch_daemons/
$ git mv launch_daemons/ launchdaemons/
By utahta, on 6月 11th, 2009%
git clone を ssh 越しにやったらエラーが出たので対処メモ。
エラーまでの軌跡
サーバ作業:
$ mkdir -p repos/test/bare
$ cd repos/test/bare
$ git --bare init
クライアント作業:
$ git clone machine:/home/user/repos/test/bare/ testdir
Initialized empty Git repository in /Users/user/Documents/projects/repos/test/testdir/.git/
bash: git-upload-pack: command not found
fatal: The remote end hung up unexpectedly
git-upload-pack なんてコマンドねーよって言われた。
クライアント側のパスはどう考えても問題なさそう。
サーバ側もパスは通ってるはずなんだけどナーと調べていくと、
どうも .bash_profile ではなくて .bashrc でパス通してあげる必要があるっぽい。
.bashrc でパス通す
サーバ作業:
$ vi ~/.bashrc
PATH=$PATH:/usr/local/git/bin
Mac 固有の問題なのかなー。
By utahta, on 6月 7th, 2009%
Git インストールでエラーが出たので対処メモ。
エラーまでの軌跡
$ wget http://kernel.org/pub/software/scm/git/git-1.6.3.2.tar.gz
$ tar zxvf git-1.6.3.2.tar.gz
$ cd git-1.6.3.2
$ ./configure --prefix=/usr/local/git-1.6.3.2
$ make
GIT_VERSION = 1.6.3.2
* new build flags or prefix
CC fast-import.o
builtin.h:6 から include されたファイル中,
fast-import.c:143 から:
cache.h:16:18: error: zlib.h: そのようなファイルやディレクトリはありません
In file included from builtin.h:6,
from fast-import.c:143:
cache.h:21: error: expected ‘)’ before ‘strm’
cache.h:22: error: expected ‘)’ before ‘strm’
cache.h:23: error: expected ‘)’ before ‘strm’
fast-import.c:280: error: ‘Z_DEFAULT_COMPRESSION’ undeclared here (not in a function)
fast-import.c: In function ‘store_object’:
...
どうやら zlib 関連がないっぽい。
ないならインストールしましょう
$ su -
# yum -y install zlib-devel
...
Complete!
# exit
もう一度試みる
$ make
$ sudo make install
成功した。