I want to add and commit a file in git without changing my current working directory. Is this possible?
> pwd
/tmp
> git --git-dir=/tmp/git_test/.git init
Initialized empty Git repository in /tmp/git_test/.git/
> ls /tmp/git_test
commit1
> git --git-dir=/tmp/git_test/.git add /tmp/git_test/commit1
fatal: '/tmp/git_test/commit1' is outside repository
> git --git-dir=/tmp/git_test/.git add commit1
fatal: pathspec 'commit1' did not match any files
(git add -A seems to use the current working directory, rather than the argument to --git-dir)