Skip to content

Instantly share code, notes, and snippets.

@connoro7
Created July 16, 2020 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save connoro7/28d595a2bda644798da96e1dba356756 to your computer and use it in GitHub Desktop.
Save connoro7/28d595a2bda644798da96e1dba356756 to your computer and use it in GitHub Desktop.
Git Dev-to-Prod Deployment Workflow

git development -> production deployment workflow

Working with 2 separate repos to store your development and production code bases.

In your development repository directory:

Add a remote for the production repository:

git remote add production git@github.com:user/production.git

Update remotes and fetch

git remote update

git fetch

create a new branch in your development repo called production from production/master remote

git checkout -b production production/master

You now have a few options.

Option 1: Pull all latest commits from development into production branch

git pull origin master

Option 2: Pick a single commit (result of a squash or bug fix) you would like to merge into production

git cherry-pick <SHA hash of commit>

If there are merge conflicts, do 2 things:

  1. fix any merge conflicts and commit
git commit -m "production release 1.0.4"
  1. retrieve production changes and replay your commits on top
git pull --rebase

push current branch head (non-master) to production master

git push production HEAD:master

Resources:

http://stackoverflow.com/questions/945654/git-checkout-updating-paths-is-incompatible-with-switching-branches

http://stackoverflow.com/questions/3598355/i-am-not-able-to-push-on-git#3598399

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment