Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Push - Username and password in the remote url

Tags:

git

github

push

As I understand password prompt when pushing to github can be avoided by adding the username:password in the remote push url.

https://you:[email protected]/you/example.git

Is this a github specific arrangement or can this format be used (https://username:[email protected]/repo.git) with any git remote?

like image 391
chamilad Avatar asked Oct 24 '14 09:10

chamilad


2 Answers

A more secured way to authenticate you through GitHub than put your password in the remote URL would be, if you use HTTPS, to generate a new token in this GitHub page and then build your remote URL like this:

https://<username>:<token>@github.com/<username>/<project_name>.git
like image 84
Hadrien TOMA Avatar answered Sep 19 '22 06:09

Hadrien TOMA


Is this a github specific arrangement?

It's not Github specific; this is actually Basic HTTP Authentication. The user:password@host trick is a way of specifying the BA credentials in the URL.

...can this format be used (https://username:[email protected]/repo.git) with any git remote?

It works only for remotes that use the HTTP protocol. For SSH remotes you'll have to use SSH Keys instead.

like image 27
Cristian Lupascu Avatar answered Sep 18 '22 06:09

Cristian Lupascu