Skip to content

Instantly share code, notes, and snippets.

@danott
Last active February 15, 2024 10:18
Show Gist options
  • Save danott/6001537 to your computer and use it in GitHub Desktop.
Save danott/6001537 to your computer and use it in GitHub Desktop.
Create a fresh staging branch from the latest deployed master.
#!/bin/bash
#
# Assumptions:
# - Clean working tree.
# - Tags are used exclusively to tag deploys
git checkout master
git branch -D staging # Delete staging branch locally.
git push origin :staging # Delete staging branch from GitHub.
git checkout -b staging `git describe --abbrev=0 --tags` # create staging from the latest deployed tag.
git push --set-upstream origin staging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment