I’m new to Git and I don’t understand how I can achieve the following.
There are 2 servers:
- Localhost
- Linode.com VPS
Basically, I want to:
- Write new code on my localhost.
- Push the new code to the development
version on the VPS where it can be
tested (at dev.domain.com or something like
that.) - If the new code is working, push it
to the production version on the
same VPS. Should be accessible at
domain.com.
What is the right way to achieve what I want?
There are several ways to do this. If you have the ability to run an ssh server on you VPS then this is fairly simple.
In your git repository on localhost you will setup two git remotes. They will have the same host but different paths (one remote for the dev path and one for the prod path).
And if you setup ssh public/private key access then you don’t have to type a password everytime.
Once you have committed the changes you want into your repo on localhost then you will do this to push them to the dev environment:
After they are verified you can then push them to production (from your repo on localhost):
If you are going to change the git repo on localhost in between pushing to dev and prod (other than fixes you want applied) then there are many ways to address this:
That doesn’t cover half your options, but maybe enough to get thinking.