There are several ways to do this. If you have the ability to run an ssh server on VPS, this is pretty simple.
In your git repository on localhost, you will configure two git remotes. They will have the same host, but different paths (one remote for the dev path and one for the prod path).
git remote add prod ssh://[ user@ ]host.xz[:port]/path/to/prod/repo.git/ git remote add dev ssh://[ user@ ]host.xz[:port]/path/to/dev/repo.git/
And if you set access to ssh public / private keys, you do not need to enter a password every time.
After you introduce the changes you want to make to your repo on localhost, you do this to push them to the dev environment:
git push dev
After they are verified, you can push them to production (from your repo to localhost):
git push prod
If you are going to change the git repository to localhost between clicking on dev and prod (except for the fixes you want to apply), there are many ways to solve this problem:
- branch or tag before clicking on dev and click to instead of the main branch (recommended anyway for other reasons).
- make a copy of the repo on the local host and click on it.
- before making changes and click on a branch instead of the main branch.
- go into VPS and just push (or pull) from dev to prod repo
It does not cover half of your possibilities, but perhaps enough to think about.
source share