tychoish, a wiki

tychoish/code/ git-readd


git-readd is a simple procedure that takes advantage of git's ability to handle rename operations implicitly. This gets a list of files that have been deleted since the last commit, and runs git rm on them to remove them from the next staged commit. Then, it adds the remaining files to the commit, and git will be able to sense which files are actually new and which files have simply been renamed. The staged commit at this point will reflect the current state of the file system.


 if [ "`git ls-files -d | wc -l`" -gt "0" ]; then
     git rm --quiet `git ls-files -d`

 git add .

This is a really brute force operation and I think the power of git is that you can construct much more nimble and precise commits. So while you won't need this very often it's good to have lying around.