Git Push - username and password in the remote URL

As I understand it, the password hint when clicking on github can be avoided by adding the username: password to the remote push url .

https://you: password@github.com /you/example.git 

Is this a specific github mechanism or can this format be used ( https://username: password@somedomain.org /repo.git ) with any remote git?

+7
source share
4 answers

Is this a specific github location?

This is not github; this is actually Basic HTTP authentication . The triple user: password@host is a way of specifying BA credentials in a URL .

... can this format be used ( https: // username: password@somedomain.org /repo.git ) with any remote git?

It works only for remotes using the HTTP protocol. For SSH remotes, you will have to use SSH keys instead.

+2
source

A safer way to authenticate via GitHub instead of entering your password in the remote URL would be if you use HTTPS to create a new token on this GitHub page , and then create the remote URL as follows:

 https://<username>:<token>@github.com/<username>/<project_name>.git 
+2
source

You can make your local Git remember GitHub credentials:

If you clone GitHub repositories using HTTPS, you can use the Credential Assistant to tell Git to remember your GitHub username and password each time it talks to GitHub.

Chekout this article is about GitHub .

0
source

Git push should not show a password starting with Git 2.9.3 (August 2016) , but to be safe, Git 2.22 (Q2 2019) improves this even further:

Previously, the remote-http transport did not anonymize the URLs reported in its error messages in some places.

See Commit c1284b2 (March 04, 2019) of Johannes dscho ( dscho ) .
(Combined Junio ​​C Hamano - gitster - in commit 764bd20 , April 16, 2019)

curl : anonymize URLs in error messages and warnings

It anonymizes URLs (read: removes them from usernames and especially passwords) in user error messages and warnings.

0
source

Source: https://habr.com/ru/post/1205427/


All Articles