Skip to content

Instantly share code, notes, and snippets.

@dkua
Last active July 29, 2020 17:23
Show Gist options
  • Save dkua/2048b941b16860d7ca18dec38ba704c7 to your computer and use it in GitHub Desktop.
Save dkua/2048b941b16860d7ca18dec38ba704c7 to your computer and use it in GitHub Desktop.
safebase – git alias for backing up branch before rebasing
[alias]
# Returns name of current branch
# Usage: git current
current = rev-parse --abbrev-ref HEAD
# Makes a full copy of the current branch with `backup.<epoch>` appended before doing an interactive rebase
# Usage: git safebase HEAD~2
safebase = !CURRENT=$(git current) && git branch -c $CURRENT $CURRENT.backup.$(date +%s) && git rebase -i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment