0
0

main branch にコミットしてしまった時の対処法

Posted at

新しいブランチを作成せずにコミットしてしまい慌ててしまったので備忘録

手順

① 新しいブランチを作成する

git checkout -b foo

② main branchに切り替える

git checkout main

③ コミットを取り消す

git reset origin/main --hard

コマンド内容

  • git checkout ブランチ名:ブランチを切り替える

  • git checkout -b ブランチ名:-b はブランチを新規作成なので、ブランチを新規作成してブランチを切り替える

  • git reset --hard:コミット内容すべてを取り消す

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0