A simple and reliable way of doing this is to have a master
branch where all of your development takes place. You can choose to rename this branch to development
if you want to more accurately reflect the branch's purpose.
You then have another production
branch that always reflects what is currently running in your production environment. Whenever you want to deploy to production, you checkout your production
branch and run git merge master
. You can also apply a tag onto the commit SHA in master
to make it easier to see at what point you deployed.
By doing it this way, you fix all your merge conflicts on your development box, and on your production box you can just run git pull
and it will fetch the latest from production
.
Here is a fancier (and potentially more complicated) alternative to the above flow. Use this if you have multiple developers and/or a more complicated release cycle is warranted.