コミットを取り消す(過去のコミットに戻す)コミットを取り消す(前回のコミットに戻す)vi test.txt # (1) test.txtを修正する git add test.txt # (2) test.txtをステージングする git commit -m 'fixed' # (3) コミットする git reset --hard HEAD^ # (4) コミットを取り消す(HEADを前回のコミットに戻す) # コミットログ'fixed'は消え、test.txtは修正前の状態に戻っている test.txt以外のファイルを修正したり、ステージングしていたとしても、前回のコミットの状態に戻っている (コミットして時間が経っていて、すでに他者が修正を行っている可能性が高い場合の)コミットを取り消す自分: git commit -am 'XXX' git push 他者: git pull git commit -am 'XXX' 自分: git revert HEAD git push (他者) git pull |
|