Bash脚本自动执行Git拉取 [英] Bash script to automate Git pull

查看:674
本文介绍了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?

推荐答案

幸运的是,根据核心

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拉取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆