Skip to content

Instantly share code, notes, and snippets.

@MMachado-uy
Last active October 15, 2019 16:50
Show Gist options
  • Save MMachado-uy/f33fe3023b133712a0003ea1192f7589 to your computer and use it in GitHub Desktop.
Save MMachado-uy/f33fe3023b133712a0003ea1192f7589 to your computer and use it in GitHub Desktop.
Go to a branch, do stuff and git back to where you were
#!/bin/bash
# Add this file with run permissions in a PATH-visible folder
# Run it from a repository with `git back` to go back to the previous branch
prev=$(git describe --all $(git rev-parse @{-1}) | sed 's/heads\///g')
git checkout $prev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment