linux - bash 脚本从 bash 脚本添加 git 凭据
问题描述
我需要能够将 git 凭据从我的 bash 脚本添加到我的 bash 脚本中,但不知道如何执行此操作。
git clone https://xxxxxxx
会询问我的用户名和密码。
我如何在 bash 脚本中传递这些?
任何指针将不胜感激
解决方案
对于基本 HTTP 身份验证,您可以:
在 url 中传递凭据:
git clone http://USERNAME:PASSWORD@some_git_server.com/project.git
警告这不安全:当您使用远程仓库时,您机器上的其他用户可以看到带有凭据的 URL
ps
或实用程序。top
-
$ git config --global credential.helper store $ git clone http://some_git_server.com/project.git Username for 'http://some_git_server.com': <USERNAME> Password for 'https://USERNAME@some_git_server.com': <PASSWORD>
使用
~/.netrc
:cat >>~/.netrc <<EOF machine some_git_server.com login <USERNAME> password <PASSWORD> EOF
推荐阅读
- c++ - 跟踪多个文件中一系列字符的频率
- html - DIV 元素相互重叠
- c++ - 错误:必须设置 CMake 工具才能进行构建。在套件选项中配置 CMake 工具
- vb.net - 使用 %USERPROFILE% 运行外部脚本
- python - OpenCV 和 Python 的立体校正问题
- eclipse - 如何有效地管理 Eclipse CDT 中构建的文件排除?
- kubernetes - 根据他们访问的数据将多个用户路由到特定的 Kubernetes pod
- javascript - Dexie startsWithIgnoreCase() 函数数组未定义
- python - 在 Python 中使用 imaplib 提取多语言电子邮件数据时解码十六进制
- mysql - MySql GRANT 错误:“选择”在此位置无效