忘備録
git branch: ローカルリポジトリのブランチの確認
git pull: リモートリポジトリの履歴を取得
git log: 作業ブランチのログの確認
git pull origin [branchname]: 作業ブランチを[branchname]に更新
git pull: リモートブランチの更新を取得して作業ブランチを更新する
git checkout -b [branchname]: ローカルリポジトリに新しいブランチを作成して作業ブランチを[branchname]に移動
git checkout [branchname]: 作業ブランチの移動
git reflog: ローカルの作業ブランチの作業履歴を取得
git reset --hard HEAD@{number}: ローカルの作業ブランチの更新をHEAD@{number}に戻す
git branch -d [branchname] : ローカルブランチを削除(マージされたものだけ有効)
git branch -D [branchname] : ローカルブランチを削除(マージされていないものも有効)
git status : 変更、追加ファイルや今のbranchの情報を表示
git add [ファイル名]: 変更をステージに追加
git add -A : 変更は全てステージに追加
git commit -m "XXXXX" : Commit コミット(メッセージも同時に書く)
git reset --soft HEAD^ : commitのやり直し(Push前)
git clean -fd : 作業ディレクトリから未追跡ファイルを一括削除
コメントをtypoした時とか
git commit --amend --m "message"
※もちろんですがPushしているコミットは出来ません
作業中に別のbranchに移動したい時
git stash save "コメント"
git stash list
stashの一覧から反映する
git stash pop stash@{番号}
git stash drop stash@{1}
// 一覧を確認
git stash list
stash@{0}: WIP on master: 1c2aadc "COMMIT_MESSAGE"
stash@{1}: WIP on master: 1c2aadc "COMMIT_MESSAGE"
// stash@{1}を反映してlistにも残す
git stash pop stash@{1}
// 一覧を確認
git stash list
stash@{0}: WIP on master: 1c2aadc "COMMIT_MESSAGE"
stash@{1}: WIP on master: 1c2aadc "COMMIT_MESSAGE"
// stash@{1}を反映してlistに残さない
git stash drop stash@{1}
// 一覧を確認
git stash list
stash@{0}: WIP on master: 1c2aadc "COMMIT_MESSAGE"
参考 http://mzgkworks.hateblo.jp/entry/git-branch-a https://qiita.com/ayakix/items/55dc4a324a49ff200c2d