Git Interactive Staging in shell script
Clone the script from github gist for you enviroment
Example:
mkdir ~/bin/
cd /bin
curl https://gist.github.com/hvasconcelos/6081058/raw/d071cf06dddace0178d92f32af59b74038e4bff4/gitistage > gitistage
chmod u+x gitistage
export PATH=$PATH:~/bin/
Code
#!/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
Written by Hélder Vasconcelos
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#