Last active
August 18, 2021 10:23
-
-
Save himanshuteotia/75dad0c9ec337af4ff8690b5650fac02 to your computer and use it in GitHub Desktop.
Create PR for hot fixes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You can follow this steps; | |
1. checkout to stage and ensure that you have the latest code | |
2. checkout to live and ensure you have the latest code | |
3. create a new branch from live , you can call it hot-fix-<simple name of the changes> e.g. "hot-fix-user-rb-api" | |
4. cherry-pick each of the commits you want from stage into the new branch you created (you can get the commit ids from the PR that contains the changes you want to hot fix) | |
5. Create a PR from the hot-fix branch -> live | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using cherry-pick
git cherry-pick allows you to pick any commits you made in any branch to any other branch. In your case you can simply checkout master branch and then cherry-pick all the commits from any branch that you wish (cherry-pick supports ranges so you can specify start and end commit instead of listing all the commits).
This way you can control the way your commits will appear in the desired branch.
For example:
git cherry-pick ebe6942..905e279
Find the range of commits you wish to re-add to your branch.
then use cherry-pick to add them back to the branch
git cherry-pick start..end
If you wish to include the start commit as well add the ^
This will result in a cherry-pick of the start commit included as well
git cherry-pick start^..end
How to find first commit of branch?
git log
print out the latest commit (first one) of the given branch
git log --oneline | tail -1
merge-base
Use the merge-base command to find where the branch was split from the original branch:
git merge-base A B