有没有办法用 git pull 在命令中输入用户名和密码,
以避免密码消息。
例如
git pull -u ahmeditman -p 123456 #this example to explain .
使用没问题
git pull http://ahmeditmna:123456@xxxxx.git
但它会从 Master Branch pull ,但是如果我需要从 dev Branch pull ?
最佳答案
It is okay to use
git pull http://ahmeditmna:123456@xxxxx.git
我想你的意思是
git clone http://ahmeditmna:123456@xxxxx.git
从技术上讲,是的。
http://username:password@domain/path
是 HTTP(S) 协议(protocol)的有效 URL 部分。但这是安全的还是你应该这样做?不。
首先,最好使用 HTTPS,如果您从公共(public)存储库中推/pull 它不会有问题,因为数据已经是公开的,但是如果它是私有(private)存储库,您的数据可能会被攻击者读取。
但更重要的部分是任何有权访问您的存储库副本的人都可以读取您的凭据。试试吧(我在这个例子中使用了第一个与 Python 相关的存储库..):
cd /tmp/
git clone 'https://username:password@bitbucket.org/mshibly/python-examples-from-intro-to-python-course.git'
cd python-examples-from-intro-to-python-course/
git remote -v
git remote -v
列表存储库的远程 URL,让我们看看:origin https://username:password@bitbucket.org/mshibly/python-examples-from-intro-to-python-course.git (fetch)
origin https://username:password@bitbucket.org/mshibly/python-examples-from-intro-to-python-course.git (push)
如您所见,您的凭据在这里,等待阅读。
如果您在服务器上使用它,那就更糟糕了,因为根据您的一般配置,您可以在日志中找到您的凭据。不说你可以通过编写脚本结束并将你的凭据放入你可以提交和/或存储在其他服务器上的脚本的事实。
这里的重点是没有充分的理由这样做,但有很多充分的理由不这样做。
不,这样做是不行的。
我建议您花一些时间学习 SSH 的工作原理和配置您的操作系统。
关于git - 使用用户名和密码执行 git pull,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53064457/