Skip to content

Instantly share code, notes, and snippets.

@leonascimento
Created April 4, 2017 14:03
Show Gist options
  • Save leonascimento/2a74411e2f9ebb5597be8d5163fb0000 to your computer and use it in GitHub Desktop.
Save leonascimento/2a74411e2f9ebb5597be8d5163fb0000 to your computer and use it in GitHub Desktop.
git-toggle
git reflog | grep 'checkout' | head -n 1 | awk '{print "git checkout " $6}' | sh -
@leonascimento
Copy link
Author

leonascimento commented Apr 4, 2017

How to use?

You should create a folder for example
gitscripts

Create in your .zshrc
PATH=$PATH:/home/your-user/Documents/gitscripts

Create a file into gitscripts folder called git-toggle
~/Documents/gitscripts/git-toggle

Give permission

chmod 755 git-toggle

Go to folder with git repository initialized.

git checkout the fist_branch
git checkout other_branch

So, now I don't remember in what branch I stayed, and now.

git toggle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment