I am using Git and manually renamed a file that I had added to the repository. Now, I have added the \"new\" file which I renamed to the repository but Git complains that th
This has to be automated. I never remember git until I commit, and I don't want to.
#!/usr/bin/env python3
# This `git rm` wrapper respects the `--cached` option (like `git rm`).
import sys
import subprocess
if "--cached" in sys.argv:
dest = sys.argv[-1]
rest = sys.argv[1:-1]
subprocess.check_call(["git", "add", dest])
subprocess.check_call(["git", "rm"] + rest)
else:
subprocess.check_call(["git", "mv"] + sys.argv[1:])
I don't want to "remember git mv", because git mv adds hidden state behind git diff that is implicitly added to the next commit, even if you explicitly commit something totally unrelated. I know, it's the so called "staged" state, but I don't like it. I like to commit without surprises.