- 追加された行はこの色です。
- 削除された行はこの色です。
* git revert (過去のコミットを取り消す逆パッチをコミットする) [#mcafd535]
*** 前提 [#e49e9401]
以下のように、あるファイルを編集して、3回コミットした。
1
2
3
4
5
↓
1 abc
2
3
4
5
↓
1 abc
2
3 xyz
4
5
このログは以下。
* 7043fc5 (HEAD -> master) #3
| diff --git a/1.txt b/1.txt
| index 6cdbd84..ca038d4 100644
| --- a/1.txt
| +++ b/1.txt
| @@ -1,5 +1,5 @@
| 1 abc
| 2
| -3
| +3 xyz
| 4
| 5
* f8584a4 #2
| diff --git a/1.txt b/1.txt
| index 8a1218a..6cdbd84 100644
| --- a/1.txt
| +++ b/1.txt
| @@ -1,4 +1,4 @@
| -1
| +1 abc
| 2
| 3
| 4
* b1e6157 #1
diff --git a/1.txt b/1.txt
new file mode 100644
index 0000000..8a1218a
--- /dev/null
+++ b/1.txt
@@ -0,0 +1,5 @@
+1
+2
+3
+4
+5
この3回のコミットのうち、2回目のコミット(f8584a4)を取り消す。
*** 手順 [#hce3eeab]
$ git revert f8584a4
[master 1ee7c5a] Revert "#2"
1 file changed, 1 insertion(+), 1 deletion(-)
git revertした結果、ファイルは以下のようになった。
1
2
3 xyz
4
5