LoginSignup
1
0

More than 1 year has passed since last update.

git pushしたことを無かったことにしたい!

Last updated at Posted at 2022-01-26

git pushしたけど間違えて違った変更を入れてしまったときに、一度git pushを取り消す方法です。
※commitした変更も全てローカルからなくなってしまうことに注意してください。

git pushを無かったことにする取り消し

ローカルの変更も同時に取り消す

// 直前のコミットを取り消す
git reset --hard HEAD^
// 変更を無かったことにしたいbranch(master)に強制的にPushする
git push -f origin master

git pushの取り消し方法

追記

直前のコミットを取り消す(変更は取り消さない)

// 直前のコミット操作を取り消す
git reset --soft HEAD^
1
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
1
0