meskerem
meskerem

Reputation: 399

How do I avoid giving username and password to git push/pull/fetch on my local machine?

Whenever I have to do push/pull/fetch a version controlled code (via Git) I always have to provide users/pass details.

I tried to setup an ssh-key but I am not familiar with that.

Is there a step-by-step guide to get started using another way to verify oneself?

Upvotes: 0

Views: 52

Answers (1)

Philipp Meissner
Philipp Meissner

Reputation: 5482

I guess you're pushing/pulling via command line. When you're requested to type in your username/password each and every time, that usually means you cloned the repository via git clone https://github.com/username/repo-name initially.

You can overcome that by cloning it via ssh like so:

git clone [email protected]:username/repo-name

Before that you should've registered your ssh-key to Github. You can read more on that topic here.

You can change how the repo is being pulled/push inside the configuration that comes with the cloned repo. Navigate into your local repository and open .git/config with your favorite editor. Then change the following block that looks similar to the following:

[remote "origin"]
    url = https://github.com/username/repo-name

to

[remote "origin"]
    url = [email protected]:username/repo-name

Afterwards, save the file and you're done.

Upvotes: 1

Related Questions