Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Git init to automatically use SSH

Tags:

git

github

I'm using Github SSH to push my files. I have ssh configured, but every time I init a new repo I need to change the .git/config file manually to change

url = https://github.com/alex3wielki/project-setup.git

to

url = ssh://[email protected]/alex3wielki/project-setup.git

but still I have to add my credentials on the first push. Is there any way to make it automatic?

like image 744
Alex Ironside Avatar asked Mar 09 '23 01:03

Alex Ironside


1 Answers

Yes

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: it's easier to set up than SSH, and usually works through strict firewalls and proxies. However, it also prompts you to enter your GitHub credentials every time you pull or push a repository.

You can configure Git to store your password for you like this below :

Store your credential using this

Caching your GitHub password in Git (Tip: You need Git 1.7.10 or newer to use the credential helper) :

git config --global credential.helper wincred

In case you want to delete your credential :

Deleting your credentials via the command line

git credential-osxkeychain erase
host=github.com
protocol=https
like image 181
napi15 Avatar answered Mar 29 '23 17:03

napi15