I git push
my work to a remote Git repository.
Every push
will prompt me to input username
and password
. I would
Wire your git client to your OS credential store. For example in Windows you bind the credential helper to wincred:
git config --global credential.helper wincred
Is there a way to skip password typing when using https:// on GitHub?
Run the following command to enable credential caching.
$ git config credential.helper store
$ git push https://github.com/repo.git
Username for 'https://github.com': <USERNAME>
Password for 'https://USERNAME@github.com': <PASSWORD>
Use should also specify caching expire,
git config --global credential.helper 'cache --timeout 7200'
After enabling credential caching, it will be cached for 7200 seconds (2 hours).
Note: Credential helper stores an unencrypted password on a local disk.
All this arises because git does not provide an option in clone/pull/push/fetch commands to send the credentials through a pipe. Though it gives credential.helper, it stores on the file system or creates a daemon etc. Often, the credentials of GIT are system level ones and onus to keep them safe is on the application invoking the git commands. Very unsafe indeed.
Here is what I had to work around. 1. Git version (git --version) should be greater than or equal to 1.8.3.
GIT CLONE
For cloning, use "git clone URL" after changing the URL from the format, http://{myuser}@{my_repo_ip_address}/{myrepo_name.git} to http://{myuser}:{mypwd}@{my_repo_ip_address}/{myrepo_name.git}
Then purge the repository of the password as in the next section.
PURGING
Now, this would have gone and
If your application is using Java to issue these commands, use ProcessBuilder instead of Runtime. If you must use Runtime, use getRunTime().exec which takes String array as arguments with /bin/bash and -c as arguments rather then the one which takes a single String as argument.
GIT FETCH/PULL/PUSH
Appears that, at least when using TortoiseGIT on Windows, it is possible to create the SSH keys and transfer these to the GIT server using simply:
> ssh-keygen.exe
> ssh-copy-id [username]@[GIT_server]
I used the answer that Pavel suggested and it worked for me. My difference was to do it while I was adding the remote like so: git remote add (alias) https://(name:password)@github.com/(the remote address).git
I was using the https link (https://github.com/org/repo.git
)
instead of the ssh link;
git@github.com:org/repo.git
Switching solved the problem for me!