简体   繁体   中英

Git cherry-pick to integration branch and then revert the original commit from feature branch

What would be the consequences of reverting the original commit while the same had been cherry-picked to the target branch?

There is a branch ( say feature ) with some changes (commit: A ), while this change was expected to be in another branch ( say integration ).
So, I cherry-picked this change (commit: A ) from feature branch to integration branch (resulting into a new commit: AC , in integration branch).

However, due to testing needs, the feature branch is not expected to contain this change (commit: A ) at all.
Hence, I had to revert A from the feature branch (resulting in a revert commit AR , in the feature branch).

Now, if later I merge this feature branch into the integration branch, would there be any issues or conflicts in the changes that had been cherry-picked initially.
[After this merge, integration will have all the 3 commits, viz. A , AR , AC ]
The commit AR will nullify the commit A , won't it nullify the commit AC too?

No, it should be fine. AR will only revert A's changes then AC will reinstall them.

Also to note : you could have considered resetting to the commit just before A ( git reset --hard A^ ) instead of reverting it, but I guess it's heavily depending on the specifics of your situation, and maybe a bit on workflow style choices.

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