hieuhtr / Blog

Don’t be lazy. Don’t make excuses. No one cares. Work fucking harder.
Other
6 stars 2 forks source link

How to revert a merged pull request in git? #13

Open hieuhtr opened 7 years ago

hieuhtr commented 7 years ago

Case study

We have a pull request that's merged to master branch But we need to revert this because of a lot of issues or this PR is not useful, etc ...

How to do this?

commit b4fcbeb56694aXXXXXXXXXXXXXX Merge: 4dfb327 141fcb8

1 Revert "Merged in SS-2141-Redis-cache-Change-connection-of-Redis-on-stage (pull request #148)" Author: Hieu Huynh hieu.huynh@XXXX.com Date: Mon Mar 6 09:52:57 2017 +0000

Merged in SS-2141-Redis-cache-Change-connection-of-Redis-on-stage (pull request #148)

SS-2141 Redis cache - Change connection of Redis on stage

Approved-by: Hieu Huynh
Approved-by: XXXX
Approved-by: XXXX

commit 141fcb88781b0d65addXXXXXXXXXXXXXXX Author: Hieu Huynh hieu.huynh@XXXXX.com Date: Mon Mar 6 14:59:29 2017 +0700

Change connection between webapp and redis service from service inside app1.stage to new Redis instance

commit 4dfb3276bacc2986dc513XXXXXXXXXXXX Merge: 21f6edf c2f1XXX Author: Hieu Huynh hieu.huynh@XXXXX.com Date: Tue Jan 17 21:51:35 2017 +0700

Merged in SS-1801-Rotate-key-access-to-bastion-server (pull request #147)

SS-1801-Rotate-key-access-to-bastion-server

- **Revert this merged PR**

commit b4fcbeb56694aXXXXXXXXXXXXXX Merge: 4dfb327 141fcb8


`b4fcbeb56694aXXXXXXXXXXXXXX` is commit-hash

**Run commands:**

git revert -m 1 git commit -m "Reverting the last commit which messed the repo." git push -u origin master