gitをいじる会(`ω´)キリッ〜その1
最近社内でGitLabが構築されて、
もしかしたらGitHubを導入するかも!??的な感じらしい。
VCSしては、
入社時はCVS、今はSubversionを使ってます。
どっちも集中型のVCSで、リモートにしかリポジトリがなくて、
IDEとか使ってない限り、自分の修正/変更履歴の確認が容易じゃなくて、
ついうっかり。。。。的なことがあったりした。
そこで、みみに入ってきたのがgitちゃん。
CVS, Subversionとは異なる分散型のリポジトリで、
開発者それぞれがローカルにリポジトリーを持っていて、
それにコミットすることで、個人の変更履歴もリビジョンで管理できる。
ローカルにコミットした上で、その変更のどこまでを
セントラルリポジトリで共有するかを決めることができるらしい。
(svn的に言うと、svn update=pullで、svn commit=pushらしい)
今回社内でせんぱいが勉強会をひらいてくれたのでその備忘録としてめもめもー!
gitのインストール
[nashuaki@hostname ~]$ sudo port install git-core +svn [nashuaki@hostname ~]$ git --version git version 1.7.11.3
バージョンを確認してインストール完了。
※Lioneだとportインストール時にmakeがないよーってエラーがでた|д゚)チラッ
Xcode関連っぽくてAppStoreからアップデートしようとしても、
エラーでアップデートできなかったよ。。。
で、
1、Xcodeを起動 2、Xcode > Preferences > Downloads 3、「Command Line Tools」をインストール
これで解消したよー。
前準備として、初期設定をしておきますよ!
[nashuaki@hostname ~]$ git config --global user.name "nashuaki" [nashuaki@hostname ~]$ git config --global user.email "hoge@hoge.com"
あと、公開鍵を使用するgitLabに追加しておく。
公開鍵がない場合は
[nashuaki@hostname ~]$ ssh-keygen -t rsa [nashuaki@hostname ~]$ cat ~/.ssh/id_rsa.pub
ちなみに、プロジェクト名はnashuaki_tipsでいきますよ!
で、早速つかってみる。
入り口は1or2のどっちかで。
1、新規のリポジトリを作成する場合
ローカルリポジトリの作成(${workspace}/nashuaki_tipsで実行時)
[nashuaki@hostname nashuaki_tips]$ git init Initialized empty Git repository in ${workspace}/nashuaki_tips/.git/
2、リモートサーバのプロジェクトを利用する場合(${workspace}で実行時)
[nashuaki@hostname ${workspace}]$ git clone gitolite@${hostname}:nashuaki_tips.git [nashuaki@hostname ${workspace}]$ git clone gitolite@${hostname}:nashuaki_tips.git Cloning into 'nashuaki_tips'... remote: Counting objects: 27, done. remote: Compressing objects: 100% (16/16), done. remote: Total 27 (delta 4), reused 0 (delta 0) Receiving objects: 100% (27/27), done. Resolving deltas: 100% (4/4), done. [nashuaki@hostname ${workspace}]$ ls -l total 0 drwxr-xr-x 5 nashuaki staff 170 8 14 22:40 nashuaki_tips
nashuaki_tipsの下には.gitディレクトリができたよー
以下、作業ディレクトリは
${workspace}/nashuaki_tips
で!
現在の状態を確認
[nashuaki@hostname nashuaki_tips]$ git status # On branch master nothing to commit (working directory clean)
ワーキングコピーとローカルリポジトリの差分はない模様
ここで、first.txtというファイルをさくせいしてみた。
[nashuaki@hostname nashuaki_tips]$ echo "hello git!!" >> first.txt [nashuaki@hostname nashuaki_tips]$ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # first.txt nothing added to commit but untracked files present (use "git add" to track)
インデックスに追加する
[nashuaki@hostname nashuaki_tips]$ git add first.txt [nashuaki@hostname nashuaki_tips]$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: first.txt #
コミットする
※ローカルリポジトリに登録
[nashuaki@hostname nashuaki_tips]$ git commit -m 'first commit.' [master 562e3ce] first commit. 1 file changed, 1 insertion(+) create mode 100644 first.txt [nashuaki@hostname nashuaki_tips]$ git status # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # nothing to commit (working directory clean)
コミットするようなワーキングコピーの変更はないですよーって言われた(*^ー゚)v ブイ♪
ここでfirst.txtに「bye」という文字列を追加してみた。
[nashuaki@hostname nashuaki_tips]$ git status # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: first.txt # no changes added to commit (use "git add" and/or "git commit -a")
first.txtが修正されましたよ
またインデックスに追加/コミットする
[nashuaki@hostname nashuaki_tips]$ git add . [nashuaki@hostname nashuaki_tips]$ git status # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: first.txt [nashuaki@hostname nashuaki_tips]$ git commit -m 'second commit.' [master da24623] second commit. 1 file changed, 1 insertion(+) $ git status # On branch master # Your branch is ahead of 'origin/master' by 2 commits. # nothing to commit (working directory clean)
ちなみに、
[nashuaki@hostname nashuaki_tips]$ git add .
の.は現在のディレクトリの変更をーってことだよ。
ここでコミットログをみてみるよー
ログの確認
[nashuaki@hostname nashuaki_tips]$ git log commit da24623194f892fa4b4dcf874a89161727265f3f Author: nashuaki <hoge@hoge.com> Date: Tue Aug 14 22:59:40 2012 +0900 second commit. commit 562e3ce07a8fc6ee41e3f6f88a8a9dd4db0c99e7 Author: nashuaki <hoge.com> Date: Tue Aug 14 22:52:24 2012 +0900 first commit. [nashuaki@hostname nashuaki_tips]$ git log -p -2 commit da24623194f892fa4b4dcf874a89161727265f3f Author: nashuaki <hoge.com> Date: Tue Aug 14 22:59:40 2012 +0900 second commit. diff --git a/first.txt b/first.txt index d1c6469..b400f6a 100644 --- a/first.txt +++ b/first.txt @@ -1 +1,2 @@ hello git! +bye commit 562e3ce07a8fc6ee41e3f6f88a8a9dd4db0c99e7 Author: nashuaki <hoge.com> Date: Tue Aug 14 22:52:24 2012 +0900 first commit. diff --git a/first.txt b/first.txt new file mode 100644 index 0000000..d1c6469 --- /dev/null +++ b/first.txt @@ -0,0 +1 @@ +hello git!
※ログの確認はオプション次第で、
最新のn件とか、n-mのリビジョンまでとか、期間の指定とかできるみたい。
- p:差分も一緒に確認
- n:最新のn件の変更を表示
リモートリポジトリ情報を登録
※cloneしてきた場合は必要ないよ!
[nashuaki@hostname nashuaki_tips]$ git remote add origin gitolite@${hostname}:nashuaki_tips.git
リモートリポジトリの確認
[nashuaki@hostname nashuaki_tips]$ git remote -v origin gitolite@${hostname}:nashuaki_tips.git (fetch) origin gitolite@${hostname}:nashuaki_tips.git (push)
プッシュする
※リモートリポジトリに登録する
※svnでいうupdateのことだよ!
[nashuaki@hostname nashuaki_tips]$ git push -u origin master Counting objects: 7, done. Delta compression using up to 2 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (6/6), 598 bytes, done. Total 6 (delta 0), reused 0 (delta 0) To gitolite@${hostname}:nashuaki_tips.git 47ef1c4..da24623 master -> master Branch master set up to track remote branch master from origin. $ git status # On branch master nothing to commit (working directory clean)
とりあえず今日はここまで!
☆おまけ☆
色をつける
[nashuaki@hostname ~]$ git config --global color.ui auto
エディタの変更(emacsにしたい)
※デフォはvimっぽい
[nashuaki@hostname ~]$ git config --global core.editor emacs
グローバル設定たちの確認
[nashuaki@hostname ~]$ git config -l user.name=nashuaki user.email=hoge@hoge.com core.editor=emacs color.ui=auto
git configの設定は
${HOME}/.gitconfig
ファイルに書いてあるのでそこをごにょごにょしたりしなかったり。
eclipseのwtp使用時にlibがデプロイされない件
毎度毎度、
ちょーーーーーーーーーどまってるので、
ここらでまとめておく。
${workspace}/.metadata/.plugins/org.eclipse.wst.server.core/tmpX/wtpwebapps/${projectName}
以下に、該当プロジェクトがdeployされる。
私の場合、
この時、
${workspace}/.metadata/.plugins/org.eclipse.wst.server.core/tmpX/wtpwebapps/${projectName}/WEB-INF/
にlibディレクトリが作成されない場合がよくよくある。
で、起動時に、
クラスがないよーーーー(°Д°;≡°Д°;)
的な感じで怒られてしまう(●´⌓`●)
そんなときは、
該当プロジェクトで
properties -> Deployment Assembly
で、
デプロイしたいものがちゃんと選択されているかを確認する!!
これでひとまずうまくいったーーーー(●´⌓`●)
maven使ってんやけど、
あまりにもうまくいかないもんだから
mvn clean dependency:copy-dependencies
dependency集めて手動コピーでしのいでたw
やっと平和に開発できるーーーーー、、、かな?
私的mysqlのソースインストール
このブログに既出の情報ばかりだけど、
いちいちつまっちゃったのでまとめとく。
ちなみに、うちの場合、環境はmacちゃん
1、環境にあったmysqlソースを本家からダウンロード(今回は5.5.25)
2、ダウンロードしたファイルを解凍。
3、解凍したディレクトリをおきたいとこに移動
※ちなみに、うちはバージョンがわかりやすいように名前をかえずにmvするので
シンボリックリンクでmysqlとしましたー
4、mysqlの初期化
[root@hostname ~]# ${basedir}/scripts/mysql_install_db --user=mysql
5、mysql起動
[root@hostname ~]# ${basedir}/support-files/mysql.server start
success(´∀`●)
・・・てまとめちゃえばあっというまだ。。。。
今回つまったのは、
mysqlの初期化のとこ。
初期化せずに起動しようとするとerrorになって、
errorファイルをみると、
なんかpluginがないよ??的なエラーがでてて、
何が悪いのやら全然わかんなかった(●´⌓`●)
(ちなみにエラーファイルは${basedir}/dataの下にあるー)
エラーは分かりやすくしないと意味ないよ!!!
自分も気をつけなきゃーと思い知らされた。。。
kyototycoonを使ってみる〜インストール編
インストールめも。
kyotocabinetをインストールする
[root@hostname ~]# wget http://fallabs.com/kyotocabinet/pkg/kyotocabinet-1.2.68.tar.gz [root@hostname ~]# tar xzf kyotocabinet-1.2.68.tar.gz [root@hostname ~]# cd kyotocabinet-1.2.68 [root@hostname kyotocabinet-1.2.68]# ./configure --prefix=/usr/local/kyotocabinet [root@hostname kyotocabinet-1.2.68]# make [root@hostname kyotocabinet-1.2.68]# make install
luaのインストール
[root@hostname ~]# port install lua
kyototycoonのインストール
[root@hostname ~]# http://fallabs.com/kyototycoon/pkg/kyototycoon-0.9.49.tar.gz [root@hostname ~]# tar xzf kyototycoon-0.9.49.tar.gz [root@hostname ~]# cd kyototycoon-0.9.49 [root@hostname kyototycoon-0.9.49]# ./configure --prefix=/usr/local/kyototycoon --with-kc=/usr/local/kyotocabinet --enable-lua --with-lua=/opt/local [root@hostname kyototycoon-0.9.49]# make [root@hostname kyototycoon-0.9.49]# make install
起動
[root@hostname ~]# /usr/local/kyototycoon/bin/ktserver
いけたヾ(。・ω・。)
さしより最新版をいれてみたけど、
起動までしかしてないから
動作は保障しません(´-ω-`)
mysql初期化/起動/停止
初期化のスクリプトがなかなか見つからなかったのでめも。
ちなみにver5.5.11
初期化
[root@hostname ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql
起動
[root@hostname ~]# /usr/local/mysql/support-files/mysql.server start
停止
[root@hostname ~]# /usr/local/mysql/support-files/mysql.server stop