Last active
December 3, 2018 09:13
-
-
Save jmatsu/9c8b075bdbe46546b3456ee747e38db7 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -eu | |
set -o pipefail | |
filter_files() { | |
local -r ref_name="$1" | |
# select files by TAB | |
git --no-pager diff --diff-filter=ACMU --name-only "$ref_name" | fzf -m | |
} | |
select_ref() { | |
(git --no-pager branch; git --no-pager branch -r) | awk '$0=$NF' | sort | uniq | fzf | |
} | |
main() { | |
local -r ref_name=$(select_ref) | |
git checkout "$ref_name" -- $(filter_files "$ref_name" | xargs) | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment