git revertを取り消す

  • 作成日 2021.06.28
  • 更新日 2022.03.01
  • git
git revertを取り消す

gitで、revertを取り消すまでの手順を掲載してます。確認用のGUIにはSourceTreeを使用してます。

環境

  • OS windows10 pro
  • git 2.30.1

revert取り消し

revertの取り消しを行うには、以下のコマンドを実行します。

git revert --abort

revert取り消しを試す

実際にrevertを行ったものを取り消してみます。

以下のコミットID「67cb54288c」を、まずは取り消しを行います。

コミットの取り消しを実行します。

git revert 67cb54288c

<出力結果>
CONFLICT (add/add): Merge conflict in hoge.js
Auto-merging hoge.js
error: could not revert 67cb542... Revert "hoge.jsを追加"
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

SourceTreeで確認すると、コミットが取り消されていることが確認できます。

この「revert」を実際に取り消してみます。

git revert --abort

SourceTreeで確認すると、「revert」したのがが取り消されていることが確認できます。