You can also use the $GIT_DIR and $GIT_WORK_TREE environment variables for the same effect as --git-dir and --work-tree
These are the steps to commit the file when you are in a different directory:
git --git-dir=/path/to/my/directory/.git/ --work-tree=/path/to/my/directory/ add myFile git --git-dir=/path/to/my/directory/.git/ --work-tree=/path/to/my/directory/ commit -m 'something'
source share