Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Any way to set default login credentials?

Tags:

git

I'm using terminal for mac and running the line

git push origin master

It asks me for my github.com username and password every time,
is there any way to have it automatically use my credentials?


I keep getting the error

error: The requested URL returned error: 403 while accessing 
https://github.com/atheycreek/churchdeploy.git/info/refs

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = https://github.com/atheycreek/churchdeploy.git

So I changed it to

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git:github.com/atheycreek/churchdeploy.git

now I get..

kirkstrobeck:churchdeploy kirkstrobeck$ git push origin master
ssh: Could not resolve hostname git: nodename nor servname provided, or not known
fatal: The remote end hung up unexpectedly

I changed it to

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = [email protected]/atheycreek/churchdeploy.git

and now i get ..

kirkstrobeck:churchdeploy kirkstrobeck$ git push origin master
fatal: '[email protected]/atheycreek/churchdeploy.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
like image 603
Kirk Strobeck Avatar asked Oct 20 '11 21:10

Kirk Strobeck


3 Answers

If on OSX, you should be able to use the osxkeychain helper. You can check to see if you already have it installed by typing:

git credential-osxkeychain

If you get a message saying that's not a valid git command, you can install it by doing:

curl -s -O http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain
chmod u+x git-credential-osxkeychain
sudo mv git-credential-osxkeychain `dirname \`which git\``

Then tell git to use it with:

git config --global credential.helper osxkeychain

You will be asked to provide your credentials once more the next time you do a pull/push. From then on, git should remember your info.

like image 34
Sean Avatar answered Oct 11 '22 17:10

Sean


From your description of things, it sounds like your [Project Dir]/.git/config file is setup with the line url = https..., and not url = [email protected].... Can you check that file to see what it says? It'd be great if you could post your entire "remote origin" section. It probably looks something like this:

[remote "origin"]
    url = https://github.com/atheycreek/churchdeploy.git
    fetch = +refs/heads/*:refs/remotes/origin/*

but needs to use ssh instead of http like this:

[remote "origin"]
    url = [email protected]:atheycreek/churchdeploy.git
    fetch = +refs/heads/*:refs/remotes/origin/*
like image 114
Colin R Avatar answered Oct 11 '22 17:10

Colin R


Setup your ssh keys appropriately with empty passphrase and you need not enter the credentials: http://help.github.com/mac-set-up-git/

like image 45
manojlds Avatar answered Oct 11 '22 15:10

manojlds