Skip to content

Instantly share code, notes, and snippets.

@RandyMcMillan
Last active February 24, 2022 23:24
Show Gist options
  • Save RandyMcMillan/9651a6d8dfa88aaa070f8640834d8fea to your computer and use it in GitHub Desktop.
Save RandyMcMillan/9651a6d8dfa88aaa070f8640834d8fea to your computer and use it in GitHub Desktop.
prepend a git branch with a UTC timestamp - with topic argument
#!/usr/bin/env bash
# Usage:
# Add this function to your .functions file so that it is available in what ever git repo you are working on.
# and
# source .functions
# or
# git clone https://gist.github.com/9651a6d8dfa88aaa070f8640834d8fea.git ~/9651a6d8dfa88aaa070f8640834d8fea
# source ~/9651a6d8dfa88aaa070f8640834d8fea
# git-checkout-b
# git-checkout-b test
function git-checkout-b (){
if [ -z "$1" ]
then
# example: 1645739209-main
git checkout -b $(date +%s)-$(git rev-parse --abbrev-ref HEAD)
else
# example: 1645739256-main-test
git checkout -b $(date +%s)-$(git rev-parse --abbrev-ref HEAD)-$1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment