1.  HOME 
  2. tech
Nov 17, 2024
Nov 17, 2024

git commit最新を残して全削除

@iniwa_jp
tech

commit全削除

例えばローカルで作業

–orphanで親のない孤児(orphan)のtmpと言う名のブランチを作る

コミットする

checkout -Bは branch -f してcheckout

tmpブランチは削除

git checkout --orphan tmp
git commit -m 'First commit'
git checkout -B main
git branch -d tmp

強制push

githubにpush

git push -f orign main

強制pull

他のマシンとかサーバーで

git checkout main
git fetch origin main
git reset --hard origin/main