💨
git command tips
特定の commit に戻す
$ git reset --hard commit_id
空 commit
$ git commit --allow-emty -m 'Some comments'
git add を取り消す
# 全てのファイルを取り消し
$ git reset HEAD
# 特定のファイルのみ取り消し
$ git reset HEAD file_name
リモートブランチをチェックアウトする
# 必要な場合、local ブランチの最新化
$ git fetch
# リモートブランチの表示
$ git branch -r
origin/HEAD -> origin/main
origin/target_branch
..
# リモートブランチをチェックアウト
$ git checkout -b target_branch origin/target_branch
# これでも行ける
$ echo 'target_branch' | xargs -I{} checkout -b {} origin/{}
Discussion