I have 3 different branches: production, development and staging. We are currently using the development branch to merge our code. However, in the last commit in development branch the build has failed. The successfully build is in the previous commit. How can I store the development commit that was successfully build into the staging branch?
This is what I’m trying to do:
- git checkout staging
- git checkout -b
- git cherry-pick my-hash-commit
But when I do that I can’t install the dependencies because I don’t have a package.json.
Is there another way of doing that?
I think you want to point your staging branch to the "last good commit". In that case:
First make sure you have no pending changes that you want to keep. Save them in a
git checkout staging git reset --hard <the-good-commit> git push
git checkout staging: go to the staging branch
git reset --hard <the-good-commit>: make the staging branch point to . The
--hardoption indicates that you want all your current files to be changed as well to have the exact contents of . If you had any uncommitted changes, they will be lost forever. Depending on your workflow you can also use
git push: push the new version of the release branch to the remote server.