I need to write a script that incrementally keeps track of files and directories added and removed from a git repo.
I have tried to use:
git log -n1 --pretty="format:" --name-only
But that only tells me which files were committed. It does not specify if it was added or removed.
Any ideas?
The option you're looking for is
--name-status
. Like--name-only
it's actually a git-diff option; git-log accepts those to determine how it'll display patches.Or equivalently (minus the log header):
As isbadawi points out, you can also use git-whatchanged. This is pretty much git-log with a specific diff output:
You might like the
--name-status
version better, though, since it doesn't show all the blob hashes, just the human-readable statuses.git whatchanged