Skip to content

Instantly share code, notes, and snippets.

@gauravkeshre
Last active March 31, 2022 12:22
Show Gist options
  • Save gauravkeshre/b63f47c59e74d7f9d76bc1a5ce9afa80 to your computer and use it in GitHub Desktop.
Save gauravkeshre/b63f47c59e74d7f9d76bc1a5ce9afa80 to your computer and use it in GitHub Desktop.
Create a CherryPick Pull request manually from terminal

Create a CherryPick Pull request manually from terminal

Considering you are working on a bugfix that needs to be merged into a release branch

Pre-requisite

  1. Make sure your branch is merged into develop
  2. Keep the SHA for the above merge handy
  3. Make sure you have latest target release branch pull in your local system

Picture - SHA of merge commit

Terminology

Let's assume that your branching model is as follow

picture of git branching model here

You are targeting to merge your fix in branch named release/march/t2 Your branch name with bugfix is named codername/bugfix/regression/T001_serious_bug Merge SHA is b3c5207e-b0e4-11ec-b909-0242ac120002

On your terminal

  1. Fetch release branch
git fetch origin release/march/t2
git checkout release/march/t2
  1. Create a new branch from release branch
git checkout -b codername/bugfix/regression/cherrypick_release_march_t2/T001_serious_bug
  1. Git cherrypick release/march/t2
git cherry-pick b3c5207e-b0e4-11ec-b909-0242ac120002

Note: If there are merge conflict, remember that HEAD is the release branch and incoming changes are your changes. So pick wisely. It is recommended to give preference to HEAD if your (incoming) changes can easily re-done.

  1. Commit and push

That's it. You can now commit and push your changes

git add .
git commit -m "Cherrypicked T001 bugfix and resolved merge conflicts"
git push origin codername/bugfix/regression/cherrypick_release_march_t2/T001_serious_bug

In the browser

  1. You can now create a Pull request from codername/bugfix/regression/cherrypick_release_march_t2/T001_serious_bug to target branch release/march/t2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment