如何在shell脚本中实现git pull而不提示用户名和密码



我需要实现"git pull origin "不需要使用shell脚本提示用户名和密码。

git pull origin Branchname

您有两个选择:

  1. 使用SSH克隆项目

    • 我不认为你想要这个,因为你要求用户名和密码。所以我将忽略它。
  2. 使用HTTPS在URL中设置用户名和密码克隆项目

    • EX:https://username:password@gitlab.com/my-project
    • 如果你已经克隆了项目,你仍然可以通过:git remote set-url origin https://username:password@gitlab.com/my-project编辑URL,你可以通过git remote -v检查你的更改
  • 注意:我建议使用特定的令牌来限制安全影响。在这里阅读更多内容:https://docs.gitlab.com/ee/security/token_overview.html

最新更新