1. 作業ディレクトリ 2. ステージングエリア(インデックス) 3. リポジトリ(ローカル、リモート)
-
git init
: 作ったディレクトリをgitで使うための宣言 -
git add
: ステージングエリアに上げる -
git commit
: リポジトリに上げる -
git log
: ログを見る -
git commit -am "---"
: addとcommitを同時に行う -
git log --oneline
: コンパクトに見る -
git log -p
: 変更された場所を具体的に見る -
git log --stat
: どのファイルが何箇所変更されたか見る -
git status
: 今ファイルがどの状態にあるか確認する(次にやることを教えてくれる) -
git checkout -- ファイル名
: チェックアウトする -
git diff
: ステージングエリアにあげる前 変更箇所を確認する -
git diff --cached
: ステージングエリアにあがってる状態(コミット前) 変更箇所を確認する -
git add .
: 今のディレクトリより下にあるファイルを全部addする -
git rm / git mv
: git上での削除 / 移動 -
.gitignore
: gitで管理したくないファイルを登録しておく 適用範囲:ディレクトリ以下 -
git commit -m "(message)"
: エディタを立ち上げずにコミットする -
git commit --amend
: 直前のコミットを変更 ログを増やしたくないとき -
git reset
元に戻す -
git reset --hard HEAD
: 直前のバージョンに戻す -
git reset --hard HEAD^
: 直前の1個前に戻す -
git reset --hard id
: idのバージョンに戻す -
git reset --hard ORIG_HEAD
: 前回取り消されたバージョンに戻す -
git branch
: 今あるブランチを確認する -
git branch (branch name)
: 新しくブランチを作る *今いるブランチ -
git checkout (branch name)
: branch nameのブランチに移動(スイッチ)する -
git merge (branch name)
: 今いるブランチにbranch nameのブランチをマージする -
git branch -d (branch name)
: branch nameのブランチを削除する
git tag (tag name)
: 直前のcommitにタグをつけるgit show (tag name)
: 指定したタグのcommitを確認するgit tag (tag name) (commit id)
: 任意のIDのcommitにタグをつけるgit tag -d (tag name)
: タグを削除する
git config --global alias.co checkout
: checkoutにcoというエイリアスをつけるgit config --global alias.st status
git config --global alias.br branch
git config --global alias.ci commit
git config -l
: 登録したエイリアスを確認する
-
git init --bare
: 作ったディレクトリをgitで使うための宣言(共有リポジトリの場合) -
git remote add origin (repos location)
: 別のリポジトリを追加 -
git remote rm
: 別のリポジトリを削除する -
git push origin master
: 共有リポジトリoriginに向かってmasterの内容をつっこむ -
git clone ~/ourweb.git/ myweb2
: 共有リポジトリourweb.gitの中身をmyweb2の中身にする -
git push
-
git pull
: 共有リポジトリの内容を自分のところへマージする -
git pull/push
-
コンフリクトの解決
『pro-git』