Bash脚本自动执行Git拉取

编程入门 行业动态 更新时间:2024-10-28 15:20:17
本文介绍了Bash脚本自动执行Git拉取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想自动从Git中拉出.由于某些原因,无法在我正在使用的服务器中自动执行密码操作.因此,它需要由Bash文件来完成.现在我的Bash编码不是很好.然后可以输入SSH密钥的密码.但是我真的不知道该怎么办...

I want to automatically pull from Git. For some reasons it is not possible to automate the password thing in the server I am using. So it needs to be done by a Bash file. Now my Bash coding is not that good. Then it is possible to enter the passphrase for the SSH key. But I have really no clue what to do...

#!/bin/bash cd . public_html/auto_deploy/foldername && git fetch --all && git checkout --force "origin/master"

#!/bin/bash cd . public_html/auto_deploy/foldername && git fetch --all && git checkout --force "origin/master"

以上操作无效...然后需要输入密码,我不知道该怎么办...我该怎么办?

The above is not working... And then it needs to enter the passphrase, and I have no idea what to do then... How can I do this?

推荐答案

幸运的是,根据核心 Git文档,您可以使用以下命令保存您的凭据供以后使用-而不是每次出现提示时都键入它.

Fortunately and according to the core Git documentation, you can use the following command to save your credentials for later on use - instead of typing it each time when prompted.

git config credential.helper store

使用此帮助程序会将您未加密的密码存储在磁盘上, 仅受文件系统权限保护.此命令将凭据无限期地存储在磁盘上,以供将来的Git程序使用.

Using this helper will store your passwords unencrypted on disk, protected only by filesystem permissions. This command stores credentials indefinitely on disk for use by future Git programs.

您可能不想直接调用此命令;它的意思是 会被git的其他部分用作凭证帮助器

You probably don’t want to invoke this command directly; it is meant to be used as a credential helper by other parts of git

有趣的检查: Git凭证

更多推荐

Bash脚本自动执行Git拉取

本文发布于:2023-11-13 09:09:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583973.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   Bash   Git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!