I try really hard to set myself up for success in the sense that I believe in setting up my environment to discourage mistakes (poka-yoke). I’ve been known to leave Office files open while I’m working in git, and occasionally things can get confused. To wit, I present a pre-commit hook that will prevent a commit if it finds Office lockfiles. It does rely on Office prefixing those lock files with ~$, but please salt to taste.
As an aside, I tend to alias git rev-parse --show-toplevel to git root, which accords with Mercurial and is a lot easier to remember.
#!/bin/sh if find $(git rev-parse --show-toplevel) -iname "~\$*" | grep -q . then echo "found Office lockfiles! Abort." 1>&2 exit 1 fi