#TIL 42 - Cherry pick from pull request

Oct 16, 2023 · Dung Huynh

What

Cherry-pick changes from any GitHub pull request directly to your local branch using hub am.

Why

Manual cherry-picking requires finding commits, copying hashes, and handling conflicts. hub am downloads and applies PR patches in one command.

How

Install hub

brew install hub

Configure

Edit ~/.config/hub:

github.com:
  - user: YOUR_USERNAME
    oauth_token: ghp_YOUR_TOKEN
    protocol: https

Apply PR

hub am -3 https://github.com/user/repo/pull/123
  • -3: three-way merge for better conflict resolution
  • URL: any PR or commit URL