要从私有Git存储库推/拉的Bash脚本? [英] Bash Script to Push/Pull from Private Git Repository?

查看:92
本文介绍了要从私有Git存储库推/拉的Bash脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种方法,可以编写一个bash脚本,该脚本将在每个午夜从我们的Private Github存储库中自动拉出并更新我们的开发站点.

I'm trying to find a way that I can write a bash script that will auto-pull from our Private Github Repository every midnight and update our development site.

由于明显的原因,我们的回购是私人的,我发现任何接近的东西总是要求输入密码.我们的服务器拥有自己的Github帐户,可用于从存储库中进行推送和拉出操作,但我只是不知道如何自动执行该操作.

Our repo is private for obvious reasons and anything close that I've found always asks for the passphrase. Our server has it's own Github Account that it uses to push and pull from the repository but I just don't know how to do that automatically.

有人能指出我正确的方向吗?

Can anyone point me in the right direction?

推荐答案

为了自动执行推/拉,您需要设置无密码身份验证.为此,请使用ssh(而不是https).如果您以前从未在github上使用过ssh,或者根本没有使用过ssh,那么您将需要执行一些步骤来进行配置.

In order to automate your push/pull, you'll need to set up passwordless authentication. To do so, you use ssh (instead of https). If you haven't used ssh with github, or at all, before, then you'll need to perform a few steps to get things configured.

在您的计算机上,生成一个ssh密钥:

On your machine, generate an ssh key:

$ ssh-keygen -t rsa

确保您将密码短语字段留空.这样就不会加密本地私钥,但对于通过Internet进行的实际通信同样安全.

Make sure you leave the passphrase field blank. This leaves the local private key unencrypted, but no less secure for the actual communication over the internet.

然后,在帐户设置|下将~/.ssh/id_rsa.pub上传到github. SSH密钥

Then, upload ~/.ssh/id_rsa.pub to github under Account Settings | SSH Keys

现在,您应该能够在没有密码的情况下从该计算机上进行推拉.试试看:

Now you should be able to push and pull from that machine without a password. Try it out:

git clone git@github.com:user/repo.git

然后可以根据需要将这些命令放入bash脚本中.如果需要在多台计算机上执行此操作,则需要上载每个密钥,或将私钥(~/.ssh/id_rsa)复制到每个密钥.

You can then put these commands in your bash script as appropriate. If you need to do this for multiple machines, you'll need to upload each key, or copy the private key (~/.ssh/id_rsa) to each one.

有关更多信息,请参见github 帮助.另外,请查看部署密钥页,因为这可以为您提供更好的安全粒度情况.

See github help for more info. Also take a look at the deploy keys page, as that may provide better granularity of security for your situation.

这篇关于要从私有Git存储库推/拉的Bash脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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