Skip to content

Instantly share code, notes, and snippets.

@rwenz3l
Created September 20, 2017 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwenz3l/b35367a9834660aac9882a0b68e0a185 to your computer and use it in GitHub Desktop.
Save rwenz3l/b35367a9834660aac9882a0b68e0a185 to your computer and use it in GitHub Desktop.
# Snippets for fun and learning more about git (automation)
function abandon-git {
rescue_branch="Rescue-Branch-$(date +"%Y-%m-%d-%H-%M-%S")"
git checkout -b "${rescue_branch}"
git add --ignore-removal .
git commit -a -m 'This is a Rescue Commit - saves progress and pushes to new banch'
git push --set-upstream origin Rescue-Branch-2017-09-20-15-54-40
}
function restore-git {
git checkout master
last_snapshot=$(git branch | grep Rescue-Branch | sort -r | head -n1 | tr -d ' ')
git merge --no-commit "${last_snapshot}"
git branch -d "${last_snapshot}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment