Created
March 10, 2020 22:34
-
-
Save sirbrillig/0e8614625154824c572ccf7fae66835e to your computer and use it in GitHub Desktop.
Git config alias for backup and restore of current branch
This file contains hidden or 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
[alias] | |
backup-create = "!f() { git branch -f backup-$(git rev-parse --abbrev-ref HEAD) && echo 'Backup created. Use git backup-restore to restore.'; }; f" | |
backup-restore = "!f() { echo 'Are you sure you want to overwrite the current branch with the latest backup? This cannot be undone!'; select result in Yes No; do [[ $result == "Yes" ]] && git reset --hard backup-$(git rev-parse --abbrev-ref HEAD) && echo 'Backup restored.'; break; done; }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment