Learn or Die

生涯勉強。Macです。

git add / git commit / git pushを取り消す

git addを取り消す

$ git reset HEAD ファイル名
#すべてのaddを取り消す
$ git reset HEAD .

覚えなくても、git statusでコマンドを確認できます。

$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   newfile.txt

git commitを取り消す

直前のコミットを取り消す。

$ git reset --hard HEAD^