Have a look at:
https://github.com/openwebwork/webwork2/wiki/Docker---things-to-get-used-to-(and-avoid-surprises) to learn some more about how Docker handles files, etc.
You would typically not want to make changes or do "git work" in "/opt/webwork/webwork2"
inside a Docker container. Overall, the data in a container reverts to the "fixed image" on each restart. I think that the manner in which webwork2 and pg are installed inside the Docker image totally removes all the "git data" (which wastes space in images) - which would explain the git commands failing inside the container. (If you are mounting webwork2 from outside the docker image, and the .git subdirectory exists there - it would probably work, but you might end up with all sorts of file ownership and permission problems.)
Instead you would probably want to edit the settings in docker-compose.yml to mount your external (on your hard disk) "webwork2" (or "pg") into the containers at start up time. Then the files on your local disk override what is fixed in the image, and you can make changes, use git, etc. in the relevant directory from outside the Docker container.
Warning: most webwork files are cached by Apache, so you need to restart Apache inside the Docker container (using "
docker container exec -it webwork2_app_1 bash" and then running "apachectl graceful" in the container) or just cycle the container: "docker-compose down; docker-compose up -d" after making changes.
You would add your GitHub form as a "git remote" using "git remote add NAME url-of-repo" (something like "git remote add personal https://github.com/taniwallach/webwork2.git"). If you are working with Docker, this would probably be done in "webwork_docker/webwork2" (outside the Docker container).