I cloned a Git repository from my GitHub account to my PC.
I want to work with both my PC and laptop, but with one GitHub account.
When I try to push to or p
For Windows Git users, after running git config --global credential.helper store
, if it still prompts for a password, you'd better check where the configuration file is written to, using this command
git config --list --show-origin
In my case, after manually editing configuration file 'C:\Program Files\Git\mingw64\etc\gitconfig', and adding the following text, it worked.
[credential]
helper = store
If you have cloned HTTPS instead of SSH and facing issue with username and password prompt on pull, push and fetch. You can solve this problem simply for UBUNTU
Step 1: move to root directory
cd ~/
create a file .git-credentials
Add this content to that file with you usename
password
and githosting URL
https://user:pass@example.com
Then execute the command
git config --global credential.helper store
Now you will be able to pull push and fetch all details from your repo without any hassle.
Apart from changing to SSH you can also keep using HTTPS, if you don't mind to put your password in clear text. Put this in your ~/.netrc
and it won't ask for your username/password (at least on Linux and Mac):
machine github.com
login <user>
password <password>
Addition (see VonC's second comment): on Windows the file name is %HOME%\_netrc
.
Also read VonC's first comment in case you want to encrypt.
Another addition (see user137717's comment) which you can use if you have Git 1.7.10 or newer.
Cache your GitHub password in Git using a credential helper:
If you're cloning GitHub repositories using HTTPS, you can use a credential helper to tell Git to remember your GitHub username and password every time it talks to GitHub.
This also works on Linux, Mac, and Windows.
Here's another option:
Instead of writing
git push origin HEAD
You could write:
git push https://user:pass@yourrepo.com/path HEAD
Obviously, with most shells this will result in the password getting cached in history, so keep that in mind.
What worked for me was to edit .git/config
and use
[remote "origin"]
url = https://<login>:<password>@gitlab.com(...).git
It goes without saying that this is an insecure way of storing your password but there are environments/cases where this may not be a problem.
You basically have two options.
If you use the same user on both machines you need to copy the .pub key to your PC, so GitHub knows that you are the same user.
If you have created a new .pub file for your PC and want to treat the machines as different users, you need to register the new .pub file on the GitHub website.
If this still doesn't work it might be because ssh is not configured correctly and that ssh fail to find the location of your keys. Try
ssh -vv username@github.com
To get more information why SSH fails.