git免密push方法

方法1 -- ssh方式

借助ssh协议,第一次输入后,以后均不需要输入。应该内置了ssh-copy-id功能。

方法2 -- HTTPS方式

https://beginor.github.io/2014/03/04/git-client-save-user-pass.html

Git 每次进行 PullPush 操作时都要输入用户名和密码, 非常不便。 虽然有客户端 SmartGit/HG 以及 TortiseGig 可以帮你记一下客户端, 但是每个代码库都要记录一次, 如果项目包含很多个 submodule 的话, 用起来也有些不方便。 经过一番搜索, 最终找到了让 git 客户端记住密码的方法, 现总结如下:

Linux/Unix/Mac 系统

新建一个 ~/.netrc 文件, 将 git 服务器, 用户名以及密码记录在这个文件, 如下所示:

machine your-git-server
login your-username
password your-password

如果有多个 server 就重复上面的三行, 分别输入对应的服务器、 用户名和密码即可;

~ 表示用户主目录, 如果你的用户名是 zhang , 那么 ~ 对应的目录是 /Users/zhang

https://comeandtechit.wordpress.com/2016/10/18/using-the-netrc-file-for-curl/

Using the netrc file for curl

Using a netrc file in curl is useful to avoid typing your password for each new request.

The syntax of your netrc file is as follows :

machine fqdn_of_your_server
login your_login
password your_password

If you log in using any LDAP-based authentication, make sure to add the DOMAIN.


machine fqdn_of_your_server
login your_login@DOMAIN
password your_password

Make sure to change the permissions on your netrc file :

chmod 600 netrc

By default, curl looks for a netrc file in your home directory.
If needed, you can manually mention the location of your netrc file :

curl --netrc-file mynetrc

猜你喜欢

转载自www.cnblogs.com/lightsong/p/12670050.html