I was in the middle of doing some long task and have already made several commits to local repo when my chief came in and asked to fix a small bug.
I've fixed it and need to deploy it to production now. However, my work from the long task is unfinished and untested, so it shouldn't go into prod. Changes from small bugfix and from long task affect different files in my repo.
How should I commit this small bugfix then push it (and only it) to prod and then recommit long task on top of the small commit (so that the history will be the same as in prod)?
Go into your release branch, or whatever it is that you deploy from.
Do a git cherry-pick <sha> where <sha> is the sha of the commit which contains your fix. This will add just that commit to this branch. You can now deploy this. Go back to your working branch and rebase it on top of the release branch.
The rebase will change history, but it's safe as long as you haven't pushed your working branch - which is likely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With