Last active
July 19, 2020 07:45
-
-
Save donchan922/6a9d725a762b9954167044f94dcc35fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# masterブランチで作業している | |
$ git branch | |
* master | |
$ git log --oneline | |
1c5a640 (HEAD -> master) Initial commit | |
# 中身は空 | |
$ cat README.md | |
# README.mdを編集する(誤った内容) | |
$ echo "Hallo World" > README.md | |
# README.mdをコミット&プッシュする | |
$ git add README.md | |
$ git commit -m "modify README.md" | |
$ git push origin master | |
# ここで、編集内容が間違っていたことに気づく | |
$ cat README.md | |
Hallo World | |
# 直前のコミットの内容を取り消したい | |
$ git log --oneline | |
3aff6a0 (HEAD -> master, origin/master) modify README.md | |
1c5a640 Initial commit | |
# 直前のコミットの内容を打ち消すためのコミットを行う | |
$ git revert HEAD | |
# 編集画面が開くので、コミットコメントを適宜編集し、「:wq」で閉じる | |
------------------------------------------------------------------- | |
Revert "modify README.md" | |
This reverts commit 3aff6a0cfe4d5908fd1978e3cbe36675afaf45a5. | |
# Please enter the commit message for your changes. Lines starting | |
# with '#' will be ignored, and an empty message aborts the commit. | |
# | |
# On branch master | |
# Your branch is up to date with 'origin/master'. | |
# | |
# Changes to be committed: | |
# modified: README.md | |
# | |
------------------------------------------------------------------- | |
# コミットの内容を打ち消すためのコミットが行われている | |
$ git log --oneline | |
245924b (HEAD -> master) Revert "modify README.md" | |
3aff6a0 (origin/master) modify README.md | |
1c5a640 Initial commit | |
# 誤った編集内容が元に戻っている | |
$ cat README.md | |
# 打ち消したコミットをプッシュする | |
$ git push origin HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment