目录
git log为:
00fbc57 (HEAD -> br10) 5
a9f80cd 4x
b097d87 3x
26b63d0 2
32ed3e2 a
文件a的内容为:
5
4
3
2
1
local_c add file a
revert单个commit
语法:
git revert commid_id
1. 回滚00fbc57
```bash
$git revert 00fbc57
$git log -3 --oneline
c10b708 (HEAD -> br10) Revert "5"
00fbc57 5
a9f80cd 4x
$ cat a
4
3
2
1
local_c add file a
// 00fbc57的提交内容消失
- 回滚b097d87
$git revert b097d87
$ git log -5 --oneline
7ab13ec (HEAD -> br10) Revert "3x"
c10b708 Revert "5"
00fbc57 5
a9f80cd 4x
b097d87 3x
$ cat a
4
2
1
local_c add file a
// b097d87的提交内容消失
revert多个commit
语法:
git revert commit_id1..commit_id2 // (commid_id1, commit_id2]
git revert commit_id1^..commit_id2 // [commid_id1, commit_id2]
$ git revert a9f80cd..00fbc57
$ git log --oneline -5
eff6c49 (HEAD -> br10) Revert "5"
00fbc57 5
a9f80cd 4x
b097d87 3x
26b63d0 2
$ cat a
4
3
2
1
local_c add file a
# git revert a9f80cd^..00fbc57
$ git log --oneline -5
dffd159 (HEAD -> br10) Revert "4x"
70f495c Revert "5"
00fbc57 5
a9f80cd 4x
b097d87 3x
$ cat a
3
2
1
local_c add file a