3

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)?

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Create a patch file from the changes you want to deploy, reset your local clone to the master branch (or whatever you use to track production), apply the patch and deploy it. Then switch back to your feature branch, merge the production branch back in and away you go.

1 Comment

Creating a patch is a bit of overkill when you already have a nice atomic commit, with a comment that you can just apply.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.