Skip to content

Instantly share code, notes, and snippets.

@hvasconcelos
Last active December 20, 2015 05:49
Show Gist options
  • Save hvasconcelos/6081058 to your computer and use it in GitHub Desktop.
Save hvasconcelos/6081058 to your computer and use it in GitHub Desktop.
Interactive Git Staging
#!/bin/bash
files=`git status --porcelain | grep -e "^\sM" | cut -d " " -f 3`
for file in $files; do
echo "Differences in file"
git diff --color=always $file
read -p "Do you want to stage this file [y/n]" to_stage
if [ "$to_stage" == "y" -o "$to_stage" == "Y" ]; then
echo "Staging file -> $file"
git add $file
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment