Given the clarification in OP's comments that he's just trying to get git code into Docker, the easiest way to do this is by using the git repo as context for the docker build file. For example, if I want code from my repo to be added to /usr/local/git/my_repo in the docker image, I'd put the Dockerfile in the root of my image and do:
ADD ./ /usr/local/git/my_repo
If you need some other repo added, this is generally something you want your automation system (i.e. Ansible, Puppet, Chef, etc...) to handle. Have your automation system pull down whatever repo(s) you need, and then move your Dockerfile to the root folder that contains all needed repos and do (assuming you'd like all of them in a folder called "my_repos" in the image):
ADD ./ /my_repos
You can expand on the idea from here, but the main tl;dr; to take away is, it's best and easiest to add stuff to a Docker image as context, and to let your automation system handle the authentication and process needed to initially get whatever stuff you want added and arrange it around the Dockerfile your building from.