Last active
August 29, 2015 14:05
-
-
Save yngwie74/b0cc3e1928f21d4e5ad5 to your computer and use it in GitHub Desktop.
Run a specific command for each file in the current repository with a given status
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
# usage: foreach "modified" "git restore" | |
# restores all the currently modified files, leaving others (deleted, renamed) alone | |
function foreach { | |
local status=$1 | |
local action=$2 | |
git status | awk '/'"$status"':/{print "'"$action"' \""$3"\""}' | bash | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment