16

When I asked to Experienced Senior about cherry pick command in git.

I got 30 Minutes big lecture about Parent-Child Node.

But Cherry Pick, He did not pick for explain. 😡

Comments
  • 7
    Git doesn't store diffs when you make a child commit of a work tree. Instead, it uses diffs to determine which files have changed, and then just saves those files wholesale.

    Cherry-Pick, on the other hand, generates a diff of the changes by X commit relative to X-1 commit (its parent), and then immediately attempts to apply them to the current work tree (whatever is currently checked out).

    If it fails, it drops you into a conflict resolution mode before continuing.

    Then, once all errors are fixed (or if the initial "patch" (application of a diff) was successful), then it also creates a new commit with the same message and author information as the cherry-picked commit.

    The end result is that you apply the changes a single commit made without doing anything with that commit's history (e.g. by a merge or rebase). This works even across unrelated branches.

    It's the quasi-equivalent of:

    git show COMMIT | git apply && git commit

    Hope that helps.
  • 4
    Also, welcome to DevRant. Solid first post :) Perhaps ease up on the emojis, though.
  • 0
    Should have cherry picked another senior
  • 1
    He explained the concept of cherry picking by cherry picking the concept he wanted to explain.
Add Comment