Skip to content

Instantly share code, notes, and snippets.

@spalger
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spalger/9331512 to your computer and use it in GitHub Desktop.
Save spalger/9331512 to your computer and use it in GitHub Desktop.
Re-stages a staged file (courtesy of @esvinson)
gitFiles=$(git status --porcelain | grep "^[ADM\?][AMD] " | sed -e "s|^[ADM\?][AMD] ||")
if [[ -n "${gitFiles}" ]] ; then
for fname in $gitFiles ; do
git add --all -- "${fname}"
echo "Restaging ${fname}"
done
else
echo "No files changed"
fi
@mrexodia
Copy link

mrexodia commented Aug 3, 2014

Personally I use:

gitFiles=$(git diff-index --name-only --cached HEAD)

Just a little bit shorter :)

Thanks for the code though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment