Created
April 29, 2014 23:07
-
-
Save russelldavis/e5173ce1269fae67baaf to your computer and use it in GitHub Desktop.
A better git-checkout
This file contains 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
#!/bin/bash | |
##### | |
# Fix the ridiculous ambiguity between branches and files in git-checkout. | |
# The new default behavior is to check out branches only. | |
# To check out a file, you must precede the filename with "--". | |
##### | |
found=false | |
for arg in "$@"; do | |
if [[ $arg == "--" ]]; then | |
found=true | |
break | |
fi | |
done | |
if ! $found; then | |
# Add "--" to the end (the first "--" is for the set command itself) | |
set -- "$@" -- | |
fi | |
exec git checkout "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment