简体   繁体   中英

GIT Cherry–Picking Commits Out Of Order

I have 1 file

I modify code on one part of the file and do commit A

I modify code on another part of the file and do commit B

If I cherry–pick Commit B from source to release first, and then Commit A at a later late, will the changes from Commit B be deleted after Commit A overrides it, or will changes from Commit A be merged into the file with changes from Commit B and both changes will stay?

A cherry pick is based on a diff from the parent. If you cherry pick B, Git will look at the difference between A and B (because A is B's parent) and that's all it will apply to release . If that difference is just "code on another part of the file", then that's all you'll get at that time.

Then later when you cherry pick A, Git will look at the difference between A and its parent, which is just the "code on one part of the file". And so that's all you'll get at that time. Nothing will be "deleted" or "overridden" — Git never behaves like that.

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