========== git初期設定========== ・自分の名前とメールアドレスの設定 git config --global user.name "sample" git config --global user.email "sample@example.com" ・カラー表示の設定(お好みで) git config --global color.ui "auto" ・設定の確認 git config --list ------------------------------ user.name=sample user.email=sample@example.com color.ui=auto ------------------------------ ・リポジトリの作成 mkdir git cd git git init ------------------------------ Initialized empty Git repository in /Users/admin/git/.git/ ------------------------------ ・リポジトリへファイルの追加 vi index.html ------------------------------

Hello World!

------------------------------ git add index.html git commit -m "add in hello world HTML" ------------------------------ [master (root-commit) 82adf64] add in hello world HTML 1 file changed, 5 insertions(+) create mode 100644 index.html ------------------------------ ・履歴の確認 git log ------------------------------ commit 82adf64f9f540f3106d59258fb25c2f74ac822bd Author: sample Date: Sat Sep 8 12:26:38 2012 +0900 add in hello world HTML ------------------------------ ・プロジェクトの作業を開始する vi index.html ------------------------------ Hello World in Git

Hello World!

------------------------------ ○gitの仕組み [作業ツリー]  | git add  ↓ [ステージングエリア]  | git commit  ↓ [リポジトリ] git init git add index.html git commit -m "add in hello world HTML" git commit -a git log git status git log -1 git branch RB_1.0 master git checkout RB_1.0 git tag 1.0 RB_1.0 git tag git checkout master git rebase RB_1.0 git branch -d RB_1.0 git branch RB_1.0.1 1.0 git checkout RB_1.0.1 git log --pretty=oneline git archive --format=tar --prefix=git-1.0/ 1.0 | gzip > git-1.0.tar.gz git clone git://github.com/tswicegood/mysite.git mysite-remote git clone git://github.com/tswicegood/mysite.git git add -i git add -p ・ショートカットの作成 git config --global alias.ci "commit" git ci = git commit git status ・作業エリアとステージングエリアの差分 git diff ・ステージングエリアとリポジトリの差分 git diff --cached ・作業エリアとリポジトリの差分 git diff HEAD ・ファイルの移動(コピーは無い) git mv index.html hello.html git clone git://github.com/tswicegood/mysite-chp4.git ・ブランチの表示 git branch ・新しいブランチの作成 git branch new git checkout -b altername master ・マージ git merge altername ・圧縮コミット(軽卒にはやらないこと) git checkout -b contact master git merge --squash contact ・チェリーピック git cherry-pick 7774183741d3a640567ae176c2b954f94cdac94a ・ブランチ名の変更 git branch -m new new2 git clone git://github.com/tswicegood/mysite-chp5.git ・詳細ログの表示 git log -p ・リビジョンの指定 git log 7b1558c -p git diff 7b1558c git diff --stat 1.0 ・コードの一部の情報表示 git blame hello.html git blame -L 12,13 hello.html git clone git://github.com/tswicegood/mysite-chp6.git git branch -r git init --bare git clone admin@localhost:/Users/admin/vremote/git git push origin master git push