Store Password
You could tell git to store your credentials using the following command:
git config --global credential.helper store
Using this method, you only need to enter your username and password once and git will never ask for it again. But please note that your password will be stored in plaintext which is not great in terms of security.
Cache Password
You can also go for caching instead which will store your password after having typed it once in a session for some period of time.
git config --global credential.helper cache
This is more secure as your password won't be stored on disk - just temporarily in memory. You can set the timeout yourself if your not happy with the default:
git config --global credential.helper 'cache --timeout=600'
Once again this is not always ideal.
SSH Agent - The Ideal Solution
What you should really be using is the ssh
protocol to push and pull your data. This will allow you to use your private ssh key to authenticate yourself - which will be handled by your operating system's installed key agent. This should work with proxies without any issues so you should definitely give it a go.
You can set it up by setting your remote url as follows:
git remote set-url origin git@github.com:<username>/<project>.git
If you are using another hosting service like bitbucket, just replace "github.com" with your providers domain.
Once you do that, you will need to set up a public and private key pair for communication between github and your computer. There is a very good tutorial on how to set it up here. If you are using Linux or MacOSX you simply need to follow the steps when running the command ssh-keygen
.
After that, you can get an SSH agent to store your password for you which is typically more secure. SSH agents usually ask you to input your password just once after turning on your computer - but after that it should do everything automatically for you. Passwords are stored securely this way unlike the first solution which stores passwords in plain text.
The SSH agent you use will depend on your operating system but it shouldn't be hard to set up. With most popular Linux distros you shouldn't need to do anything and I have been informed in a comment below that you can set Windows up as follows:
git config --global credential.helper wincred
I have never used MacOSX so I cannot say for certain whether this is automatically set up like it is in Ubuntu based distributions.