Skip to content

Instantly share code, notes, and snippets.

@morganestes
Created January 8, 2016 21:46
Show Gist options
  • Select an option

  • Save morganestes/ccec34bd27dd07b61235 to your computer and use it in GitHub Desktop.

Select an option

Save morganestes/ccec34bd27dd07b61235 to your computer and use it in GitHub Desktop.
Custom Git commands for my workflow
This is a collection of Git commands I use on a regular basis.
#!/usr/bin/sh
#
# "Archive" the current branch
#
# Once a feature branch has been code reviewed, approved, and merged,
# tag it in it's current state and save it for later.
#
readonly local_branch=$(git whereami)
readonly archive_branch="archive/${local_branch}"
upstream="origin" || "$1"
main() {
archive_tag
remove_archived_branch
}
archive_tag() {
git tag "${archive_branch}"
git push "${upstream}" "${archive_branch}"
}
remove_archived_branch() {
git checkout master
#local
git branch -d "${local_branch}"
#upstream
git push origin --delete "${local_branch}"
}
main "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment