Skip to content

Instantly share code, notes, and snippets.

@m3dwards
Created April 22, 2016 12:31
Show Gist options
  • Save m3dwards/09f6a4ed8d345012ba2b2af7c9a60955 to your computer and use it in GitHub Desktop.
Save m3dwards/09f6a4ed8d345012ba2b2af7c9a60955 to your computer and use it in GitHub Desktop.
Better git add
function ga {
{ git ls-files -o --exclude-standard --full-name | while read -r file; do
read -u 3 -n 1 -p "Do you wish to add new file \"$file\"? (y/n) " answer
if echo "$answer" | grep -iq "^y" ;then
git add $file
echo $'\nAdded file\n'
else
echo $'\nSkipping file\n'
fi
done; } 3<&0
git add -p
}
ga
@m3dwards
Copy link
Author

m3dwards commented Apr 22, 2016

Will first ask you if you wish to add each new untracked file and then will start the normal "patched" mode of git adding each hunk.

Should make it easy to do sanity check before adding items.

Just lift function definition into .bashrc.

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