简体   繁体   中英

Cherry-picking merge commits

Let's say I've got this scenario:

  sprint branch  - - - --30------60----- - - - ---150----
                                /     
  some fixes    - - ---57-----59    
                             /    
  some more fixes  - ------58     

Now we realize we don't need the fixes merged in commit 60.

How can we revert them without removing everything else that was commited afterwards?

Use git revert -m 1 60 . This will create a commit that undoes everything brought in from commit 60 (ie everything in 57, 58, 59, and all the other commits in the "some fixes" and "some more fixes" branch).

Note that if you want to bring in those fixes in the future, however, you won't be able to just merge commit 60 in again. Instead, you will have to "revert the revert," ie call git revert on the commit that the original git revert created.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM