0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

コミット⇒プルリクエスト後にコミット前に戻す方法

Posted at

プルリクエスト後に修正誤りに気付いたときに調べたことを備忘録としてまとめました。

プルリクエストを元に戻す

プルリクエスト一覧から、削除したいプルリクエストのページに進み、ページ下部にある「Close pull request」または「プルリクエストを閉じる」ボタンをクリックすることで、プルリクエストを閉じることができます。

プッシュしたコミットを取り消す

①ローカルの作業ディレクトリで、リモートリポジトリから最新の状態を取得します。(<branch-name>は、コミットを元に戻したいブランチの名前)

git pull origin <branch-name>

②取り消したいコミットのハッシュ値(コミットID)を確認します。
コミットIDは、'git log'コマンドで履歴を表示することで取得できます。

git log

③指定したコミットを取り消す新しいコミットを作成します。
'git revert'コマンドは、指定したコミットによって加えられた変更を取り消す新しいコミットを作成します。

git revert <commit-id>

以上手順でコミット前の状態に戻すことができます。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?