Skip to content

Instantly share code, notes, and snippets.

@vincentbernat
Created July 14, 2016 13:14
Show Gist options
  • Save vincentbernat/18a0413ed8b9cf6ecc926770871a0667 to your computer and use it in GitHub Desktop.
Save vincentbernat/18a0413ed8b9cf6ecc926770871a0667 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -xe
mkdir zones
cd zones
git init
git checkout -b staging
for i in $(seq 1 20); do
echo $i >> f1
echo $i >> f2
done
git add f1 f2
git commit -m "Initial commit"
git checkout -b prod
git checkout -b remote-prod
git checkout -b remote-staging
git checkout staging
# At this point, all branches are the same. Add a line to f1.
sed -i '8iAdditional line' f1
git add f1
git commit -m "f1 modified"
# Add a line to f2
sed -i '10iAdditional line' f2
git add f2
git commit -m "f2 modified"
# Cherry-pick for production
git checkout prod
git cherry-pick -x -Xtheirs staging
# Merge remotes
git diff remote-prod
git merge --no-ff remote-prod
git checkout remote-prod
git reset --hard prod
git checkout remote-staging
git reset --hard staging
# Do another modification to f2
git checkout staging
sed -i 10d f2
git add f2
git commit -m "f2 modified again"
# Cherry-pick for production
git checkout prod
git cherry-pick -x -Xtheirs staging
# Merge remotes
git diff remote-prod
git merge --no-ff remote-prod
git checkout remote-prod
git reset --hard prod
git checkout remote-staging
git reset --hard staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment