Last active
February 24, 2022 23:24
-
-
Save RandyMcMillan/9651a6d8dfa88aaa070f8640834d8fea to your computer and use it in GitHub Desktop.
prepend a git branch with a UTC timestamp - with topic argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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