git === "" 過去のcommitのログ ------------------------- HEAD^にて「^の数だけ前のcommit」を示せる。つまり、以下の通り。 ``` currentとは「今のcommitしていない」ものです HEADと1個のcommit(つまり、最後のcommit差分) currentではない git diff HEAD HEAD^ currentと)1個のcommitとの差分 git diff HEAD^ currentとHeadとの差分(つまり、git diffと一緒) git diff HEAD 1個前のcommit差分(^を重ねる) git diff HEAD^ HEAD^^ 特定のcommitIDとの差分 git diff remoteのorigin(トラックしているレポジトリ)のorigin branchに関する情報 git remote show origin ``` ## レポジトリの始め方 ``` cd ~/repos/ mkdir test cd test git --bare init cd (適当に追加) git push origin master git branch stable git checkout stable git push origin stable git checkout master ``` ## master開発時のpull手順 ``` git fetch -p git merge origin/master ``` master開発時のpatch開発手順 -------------------------------- ``` git checkout -b hogehoge > -bによって、branchを切ってcheckout(移動)する git branch > branchが移ったことを確認 git branch -r > remoteのbranchを確認 git branch -a > remoteを含んだbranchを確認できる ``` ``` git reset --hard > とにかく、checkoutしているやつまで戻す ``` ``` git branch -D i18n > branchを消す ``` ## 他の開発者のPC ``` git clone git pull origin master git branch git pull origin stable ``` ## masterへのマージ ``` git branch master git merge --no-ff hogehoge git commit // git merge --no-ff master 4dc2475042c2d6dc30691a462c56579311352d などでcommit idでpullできる ff: コンフリクトが発生しないマージのとき、マージコミットを作らない no-ff: コンフリクトがなくてもマージコミットを作る ``` ## マージ後の処理 ``` git pull origin master git branch -D hogehoge > 削除 ``` ## タグをつける ``` git tag 0.0.1 git push --tags ``` ## Branch関係のログ ``` git log --color --graph --oneline --all --decorate git log --graph --oneline --decorate --tags --branches --remotes --color ``` ## 間違えてBranchをremote originにpushしてしまった! ``` git remote show origin > 対象を確認する * remote origin Fetch URL: file:///home/kanai/repos/test Push URL: file:///home/kanai/repos/test HEAD branch: master Remote branches: func/001 new (next fetch will store in remotes/origin) git push --delete origin func/001  > 削除 To file:///home/kanai/repos/test - [deleted] func/001 git remote show origin | grep func > 必要かはおいておいて確認 ``` ## 参照しているHEADのcommitを見る ``` cat .git/HEAD ref: refs/heads/master cat .git/refs/heads/master fffffffff31290832904890312ffffffffff ```