morganestes
1/8/2016 - 9:46 PM

Custom Git commands for my workflow

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"