If Git prompts you for a username and password every time you try to interact with GitHub, you're probably using the HTTPS clone URL for your repository. Using an HTTPS remote URL has some advantages compared with using SSH.
The git pull command is actually a combination of two other commands, git fetch followed by git merge . In the first stage of operation git pull will execute a git fetch scoped to the local branch that HEAD is pointed at. Once the content is downloaded, git pull will enter a merge workflow.
This is not exactly what you asked for, but for http(s):
https://user:pass@domain/repo
but that's not really recommended as it would show your user/pass in a lot of places...Usage examples for credential helper
git config credential.helper store
- stores the credentials indefinitely.git config credential.helper 'cache --timeout=3600'
- stores for 60 minutesFor ssh-based access, you'd use ssh agent that will provide the ssh key when needed. This would require generating keys on your computer, storing the public key on the remote server and adding the private key to relevant keystore.
I found one way to supply credentials for a https connection on the command line. You just need to specify the complete URL to git pull and include the credentials there:
git pull https://username:[email protected]/my/repository
You do not need to have the repository cloned with the credentials before, this means your credentials don't end up in .git/config
. (But make sure your shell doesn't betray you and stores the command line in a history file.)
Doesn't answer the question directly, but I found this question when searching for a way to, basically, not re-enter the password every single time I pull on a remote server.
Well, git
allows you to cache your credentials for a finite amount of time. It's customizable in git config
and this page explains it very well:
https://help.github.com/articles/caching-your-github-password-in-git/#platform-linux
In a terminal, run:
$ git config --global credential.helper cache
# Set git to use the credential memory cache
To customize the cache timeout, you can do:
$ git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)
Your credentials will then be stored in-memory for the requested amount of time.
Below cmd will work if we dont have @ in password:
git pull https://username:pass@[email protected]/my/repository
If you have @ in password then replace it by %40 as shown below:
git pull https://username:pass%[email protected]/my/repository
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With