Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Basic workflow for creating a cherry-pick pull request for ansible

After submitting a PR to Ansible for the devel branch, and having it merged, the following instructions will help you create a pull request to backport the change to a previous stable branch

These instructions assume that stable-2.5 is the previous release branch.

  1. Update devel, to ensure you have the commit to cherry pick:

    git checkout devel
    git --fetch upstream
    git merge upstream/devel
    git checkout stable-2.5
    git pull
    git checkout -b cherry-pick/2.5/[PR_NUMBER_FROM_DEVEL]
    git cherry-pick -x [SHA_FROM_DEVEL]
  2. Add a changelog entry for the change, and commit it

  3. Push your branch to your fork:

    git push origin cherry-pick/2.5/[PR_NUMBER_FROM_DEVEL]
  4. Submit PR for cherry-pick/2.5/[PR_NUMBER_FROM_DEVEL] against the stable-2.5 branch

The choice to use cherry-pick/2.5/[PR_NUMBER_FROM_DEVEL] as the feature branch is somewhat arbitrary, but conveys meaning about the purpose of that branch. It is not required to use this format, but it can be helpful, especially when making multiple backport PRs for multiple stable branches.

Copy link

nitzmahone commented Feb 21, 2018

This looks like a good start- only other "assumption" you might want to add is around the definitions of origin and upstream, as those aren't always consistent (eg, origin for me is always ansible/ansible- I create multiple named remotes for the various forks I might push to).

I usually do cherry-picks with a disconnected HEAD right off the remote branch instead of transiting through local branches, which gets rid of a couple of steps (and potential for "leaking" other changes in- more important for direct push, less so when using PRs), but this is probably more "idiomatic git" for the way most people do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment