developer_c 將未測過的分支merge到主分支上,然而要如何處理此情況?
(下圖中 developer_c 所有的提交都是沒測過的,線上git log沒有的)
$ git log --graph --decorate
* commit 17d7378fbc6158ba78dda5bee3888946262dae00 (origin/v/1.0)
| Author: developer_c <you@example.com>
| Date: Wed Aug 1 14:27:36 2018 +0800
|
| developer_c commit 2
|
* commit 343d7522c01f0a23694c23bf100e64c73fd564ac
|\ Merge: 11a53f7 d785818
| | Author: developer_c <you@example.com>
| | Date: Wed Aug 1 14:26:41 2018 +0800
| |
| | Merge branch 'v/1.0' of www.gitlab.com:root/admin into v/1.0.cy
| |
| * commit d7858187c1047c3070b7cf22e8ecc73662fa36ff
| |\ Merge: 3152999 3aa9df2
| | | Author: developer_y <developer_y@example.com>
| | | Date: Mon Jul 30 16:43:21 2018 +0800
| | |
| | | Merge branch 'v/1.0' of www.gitlab.com:root/admin into v/1.0
| | |
| | * commit 3aa9df2a1bce8a2140dbdc284c99281101d13c28
| | | Author: developer_k <developer_k@developer_k-VirtualBox>
| | | Date: Sat Jul 28 14:39:24 2018 +0800
| | |
| | | developer_k commit 3
| | |
| | * commit 5613362f2dd3f880dd51e93490674b09ad002658
| | | Author: developer_k <developer_k@developer_k-VirtualBox>
| | | Date: Sat Jul 28 13:42:34 2018 +0800
| | |
| | | developer_k commit 2
| | |
| | * commit c1c959dff6814d3265f83a74abe7ada284d1fcd4
| | | Author: developer_k <developer_k@developer_k-VirtualBox>
| | | Date: Fri Jul 27 18:44:38 2018 +0800
| | |
| | | developer_k commit 1
| | |
| | * commit 061a2e49e399a52fa9750f6ac283f00bdfdbc839
| | | Author: developer_b <developer_b@example.com>
| | | Date: Thu Jul 26 16:55:41 2018 +0800
| | |
| | | developer_b commit 1
| | |
| * | commit 315299970b9e47c35e1f5b623fbfc063a9f2f2b7
| |/ Author: developer_y <developer_y@example.com>
| | Date: Mon Jul 30 16:43:01 2018 +0800
| |
| | developer_y commit 4
| |
| * commit ea2d0d563cfd576a59d174d684411d3d7209f7c4
| | Author: developer_y <developer_y@example.com>
| | Date: Thu Jul 26 10:03:13 2018 +0800
| |
| | developer_y commit 3
| |
* | commit 11a53f77caf39dc0444852d97e7e647cf1a2227c
|\ \ Merge: daa70a6 67528e6
| |/ Author: developer_c <you@example.com>
| | Date: Wed Jul 25 18:49:01 2018 +0800
| |
| | Merge branch 'v/1.0' of www.gitlab.com:root/admin into v/1.0.cy
| |
| * commit 67528e6cd2e20c128637f23adb9672d7eddfbca4
| | Author: developer_y <developer_y@example.com>
| | Date: Tue Jul 24 15:27:15 2018 +0800
| |
| | developer_y commit 2
| |
| * commit 24ea51e72478735b03a86e9beab9d49036d62278
| | Author: developer_y <developer_y@example.com>
| | Date: Mon Jul 23 13:51:06 2018 +0800
| |
| | developer_y commit 1
| |
* | commit daa70a6a8514ee0ff790b15433f92d0d2f58d6c7 (origin/v/1.0.cy)
|/ Author: developer_c <you@example.com>
| Date: Fri Jul 20 10:27:21 2018 +0800
|
| developer_c commit 1
|
$ git revert 17d7378fbc6158ba78dda5bee3888946262dae00
Merge branch 'v/1.0' of www.gitlab.com:root/admin into v/1.0.cy ( 343d752 ) 因為是merge 的commit ,必須指名 -m 參數才能revert。然而這分支中間又合併了一次 Merge branch 'v/1.0' of www.gitlab.com:root/admin into v/1.0.cy (11a53f7)
所以必須 -m 2 把 343d752 分支上的 11a53f7 和 daa70a6 回復
$ git revert -m 2 343d7522c01f0a23694c23bf100e64c73fd564ac
使用git log -p file_name、 git show commit 檢查中間commit(如 3aa9df2、3152999)的修改沒有受影響
參考資料:
https://stackoverflow.com/questions/7099833/how-to-revert-a-merge-commit-thats-already-pushed-to-remote-branch How to revert a merge commit that's already pushed to remote branch?
沒有留言:
張貼留言