在我的 GoDaddy 托管计划上设置 git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1003885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 06:36:40  来源:igfitidea点击:

Setting up a git repo on my GoDaddy hosting plan

git

提问by Tom Wright

I have a project which is version-controlled using git.

我有一个使用 git 进行版本控制的项目。

What I want to be able to do is set up a repo on my (ssh-enabled) GoDaddy shared hosting package so that I can deploy with a push rather than dragging and dropping in FTP.

我想要做的是在我的(启用 ssh 的)GoDaddy 共享托管包上设置一个存储库,以便我可以通过推送而不是在 FTP 中拖放进行部署。

Any tips would be appreciated. Best would be an account from someone who's already done it, but I couldn't personally find any online.

任何提示将不胜感激。最好是已经做过的人的帐户,但我个人在网上找不到任何帐户。

回答by jotr

With a little work, I was able to get Git running on my GoDaddy account. There's a longer posting detailing the process on my blog, but the short answer is:

通过一些工作,我能够在我的 GoDaddy 帐户上运行 Git。在我的博客上有一篇更长的帖子详细介绍了这个过程,但简短的回答是:

  1. install git in your account (perhaps using the tarball referenced in my blog post)
  2. create a git repository (bare or not) in your account
  3. check out your repository, using -u to indicate the path to git-upload-pack

    % git clone -u libexec/git-core/git-upload-pack mysite:myrepo.git

  4. tweak your local repository config to point to the correct paths to git-upload-packand git-receive-pack:

    % git config remote.origin.receivepack libexec/git-core/git-receive-pack
    % git config remote.origin.uploadpack libexec/git-core/git-upload-pack

  1. 在您的帐户中安装 git(可能使用我博客文章中引用的 tarball)
  2. 在您的帐户中创建一个 git 存储库(裸与否)
  3. 检查您的存储库,使用 -u 指示到的路径 git-upload-pack

    % git clone -u libexec/git-core/git-upload-pack mysite:myrepo.git

  4. 调整你的本地仓库config来指向正确的路径git-upload-packgit-receive-pack

    % git config remote.origin.receivepack libexec/git-core/git-receive-pack
    % git config remote.origin.uploadpack libexec/git-core/git-upload-pack



Since the blog is no longer accessible, here is the full post pulled from archive.org:

由于该博客不再可访问,以下是从archive.org 中提取的完整帖子:

Using Git on GoDaddy

在 GoDaddy 上使用 Git

This blog is hosted on a cheap GoDaddy account. When shell access over SSH was recently made available, I thought it would be fun to install local git repositories. It wasn't trivial, but I did finally get it working. Here's how I did it:

该博客托管在廉价的 GoDaddy 帐户上。当最近可以通过 SSH 访问 shell 时,我认为安装本地 git 存储库会很有趣。这不是微不足道的,但我终于让它工作了。这是我如何做到的:

Step 0. Configure SSH

步骤 0. 配置 SSH

You want to create a public key so you can SSH in to your GoDaddy account painlessly. Create a key pair if you don't already have one, and add it to ~/.ssh/authorized_keys. I'll assume an entry in ~/.ssh/configsomething like this:

您想创建一个公钥,以便轻松通过 SSH 连接到您的 GoDaddy 帐户。如果您还没有,请创建一个密钥对,并将其添加到~/.ssh/authorized_keys. 我会假设一个条目~/.ssh/config是这样的:

Host mysite
HostName mygodaddysite.com
User mylogin

Step 1. Install Git

步骤 1. 安装 Git

After poking around on my GoDaddy host, I discovered it was running CentOS 5.2. Binaries running on my laptop weren't compatible, so I used VirtualBox to set up a local Centos 5.2 install and build Git. I'm sharing a tarball containing the pre-built CentOS 5.2 Git binaries. You should be able to download and install with the commands:

在我的 GoDaddy 主机上闲逛后,我发现它运行的是 CentOS 5.2。在我的笔记本电脑上运行的二进制文件不兼容,所以我使用 VirtualBox 来设置本地 Centos 5.2 安装并构建 Git。我正在分享一个包含预先构建的 CentOS 5.2 Git 二进制文件的 tarball 。您应该可以使用以下命令下载和安装:

wget http://johntrammell.com/centos5.2-git.tar.gz
tar xzf centos5.2-git.tar.gz

Enjoy this part–I've saved you a couple hours' work here.

享受这部分——我在这里为您节省了几个小时的工作。

Step 2. Set up your environment.

步骤 2. 设置您的环境。

Add the following to your .bash_profile:

将以下内容添加到您的 .bash_profile 中:

export EDITOR=vim
export PATH=$PATH:$HOME/bin:$HOME/libexec/git-core
export LD_LIBRARY_PATH=$HOME/lib
export GIT_EXEC_PATH=~/libexec/git-core
export GIT_TEMPLATE_DIR=~/share/git-core/templates

This will set your environment up correctly on an interactive shell. Unfortunately I can't seem to get the PATH to set correctly for non-interactive SSH commands. For example, when I run this command from my laptop:

这将在交互式 shell 上正确设置您的环境。不幸的是,我似乎无法为非交互式 SSH 命令正确设置 PATH。例如,当我从笔记本电脑运行此命令时:

ssh mysite env

I see the default PATH. This is also the case when I set the path in .bashrc. I haven't tracked down exactly what SSH does on non-interactive access, but this may be related to the PermitUserEnvironment setting in sshd. Luckily we can work around this.

我看到了默认的 PATH。当我在 .bashrc 中设置路径时也是如此。我还没有确切地追踪到 SSH 在非交互式访问中做了什么,但这可能与 sshd 中的 PermitUserEnvironment 设置有关。幸运的是,我们可以解决这个问题。

Step 3. Creating a repository

步骤 3. 创建存储库

Log in to your GoDaddy account, and create a simple “bare” Git repository:

登录您的 GoDaddy 帐户,然后创建一个简单的“裸”Git 存储库:

% mkdir myrepo
% cd myrepo
% touch README
% git init
% git add README
% git commit -m 'empty git repository'
% cd ..
% git clone --bare myrepo myrepo.git

You now have a bare repository in ~/myrepo.git/in the root of your GoDaddy account.

您现在在~/myrepo.git/GoDaddy 帐户的根目录中有一个裸存储库。

Step 4. Checking out your repository

第 4 步。检查您的存储库

The only tricky part to this is that you have to tell git where to find git-upload-pack. This works around the PATH problem mentioned above. On your local machine, do this:

唯一棘手的部分是你必须告诉 git 在哪里可以找到 git-upload-pack。这可以解决上面提到的 PATH 问题。在您的本地机器上,执行以下操作:

git clone -u libexec/git-core/git-upload-pack mysite:myrepo.git

You should now have a copy of the original minimal repository checked out.

您现在应该已检出原始最小存储库的副本。

Step 5. More git configuration tweaks

第 5 步。更多 git 配置调整

Sadly we are not done:

遗憾的是,我们还没有完成:

% cd myrepo
% echo "foo" > README
% git commit -am 'updated'
[master 044c086] updated
 1 files changed, 1 insertions(+), 0 deletions(-)
% git push
bash: git-receive-pack: command not found
fatal: The remote end hung up unexpectedly

Our PATH problems are interfering with the push operation now. As a workaround, we can either specify –receive-pack on the command line, or set it in the local configuration (the same applies for fetch operations and –upload-pack):

我们的 PATH 问题现在正在干扰推送操作。作为一种解决方法,我们可以在命令行中指定 –receive-pack,或者在本地配置中设置它(这同样适用于 fetch 操作和 –upload-pack):

% git config remote.origin.receivepack libexec/git-core/git-receive-pack
% git config remote.origin.uploadpack libexec/git-core/git-upload-pack

Congratulations, you should be up and running now!

恭喜,您现在应该可以正常运行了!

Resources

资源

回答by tbc

I was successful following the directions here:

我按照这里的指示成功了:

http://www.krizka.net/2010/12/30/setting-up-a-public-git-repository-with-godaddy-shared-hosting/

http://www.krizka.net/2010/12/30/setting-up-a-public-git-repository-with-godaddy-shared-hosting/

The keys (for me) were

钥匙(对我来说)是

  • Getting the precompiled binary for CentOS (from a link in post above)
  • Setting the "uploadpack" and "receivepack". This is step 1 in the section "Letting local git know about remote git" near the end of the post.
  • 获取 CentOS 的预编译二进制文件(来自上面帖子中的链接)
  • 设置“uploadpack”和“receivepack”。这是文章结尾附近的“让本地 git 了解远程 git”部分中的第 1 步。

回答by gahooa

First, you will need to have git installed on GoDaddy. I'm not sure if this is possible. Git supports local user installs, but you need to have certain development tools handy to do it. Download git, and see if you can ./configure && make && make install-- if so, it will put it in your ~/bindirectory.

首先,您需要在 GoDaddy 上安装 git。我不确定这是否可能。Git 支持本地用户安装,但您需要手边有某些开发工具才能执行此操作。下载 git,看看你是否可以./configure && make && make install——如果可以,它会将它放在你的~/bin目录中。

We use git extensively for controlling production. But rather than deploying on push, may I suggest that you ssh to the box and do a git pull?

我们广泛使用 git 来控制生产。但是,与其在推送时部署,我可以建议您通过 ssh 连接到盒子并执行git pull?

More specifically, create a "Release" branch, and then when you are ready to deploy, simply merge your changes into the Release branch, ssh to the server, and git pull.

更具体地说,创建一个“发布”分支,然后当您准备好部署时,只需将您的更改合并到发布分支、ssh 到服务器和 git pull。

For example

例如

ssh [email protected]
cd /path/to/project

#ok, assuming you are on the Release branch
git fetch
git merge branch-with-new-changes-on-it

# update the remote Release branch with the merge
git push origin HEAD

This simple workflow allows developers to see exactlywhat is on the production server at all times, and to merge other changes in with theirs before asking for a deployment. In fact, we require that all production changes be fully merged before requesting a deployment of your branch.

这个简单的工作流程允许开发人员始终准确地查看生产服务器上的内容,并在要求部署之前将其他更改与他们的更改合并。事实上,我们要求在请求部署您的分支之前完全合并所有生产更改。

--

——

If you do manage to get git installed on GoDaddy, and you REALLY want to auto-deploy when you push to it, then take a look at the post-updatehook.

如果您确实设法在 GoDaddy 上安装了 git,并且您真的想在推送到它时自动部署,那么请查看post-update钩子。

http://git-scm.com/docs/githooks

http://git-scm.com/docs/githooks

--

——

If you cannot get git installed on GoDaddy, then see if they support rsync. Then you can have a simple bash script somewhere that will

如果您无法在 GoDaddy 上安装 git,请查看它们是否支持 rsync。然后你可以在某处有一个简单的 bash 脚本

  1. pull your changes
  2. rsync them to godaddy
  1. 拉动您的更改
  2. 将它们同步到 Godaddy

--

——

There are many ways to do it. Perhaps this will help with direction a bit...

有很多方法可以做到。也许这会有助于方向...

回答by Lance Caraccioli

I maitain git locally and use scp to push live... it's not elegant, but godaddy has scp installed my default.

我在本地维护 git 并使用 scp 进行实时推送……这并不优雅,但 Godaddy 已安装了我的默认设置 scp。

"scp -r fooDirectory [email protected]:/path/to/document/root/"

“scp -r fooDirectory [email protected]:/path/to/document/root/”

that will move a local directory "fooDirectory" to "/path/to/document/root/fooDirectory" on the remote host.

这会将本地目录“fooDirectory”移动到远程主机上的“/path/to/document/root/fooDirectory”。

when you are logged into go daddy use "pwd

当您登录 go daddy 时,请使用“pwd

回答by inf3rno

Connect via ssh.

通过 ssh 连接。

Install git to ~/git.

将 git 安装到 ~/git。

After that create/update these files:

之后创建/更新这些文件:

~/.ssh/authorized_keys

~/.ssh/authorized_keys

command="~/connect.sh" ssh-rsa AAAAB3NzaC...

~/connect.sh

〜/connect.sh

#!/bin/bash
if [ -f "${HOME}/.env_profile" ]; then
        source ~/.env_profile
fi;

if [ "x${SSH_ORIGINAL_COMMAND}x" == "xx" ]; then
        $SHELL --login
else
        eval "${SSH_ORIGINAL_COMMAND}"
fi;

~/.env_profile

~/.env_profile

export ENV_VARIABLE=value

by git:

通过 git:

export PATH=$PATH:$HOME/bin:$HOME/git/libexec/git-core
export LD_LIBRARY_PATH=$HOME/git/lib
export GIT_EXEC_PATH=~/git/libexec/git-core
export GIT_TEMPLATE_DIR=~/git/share/git-core/templates

I spent about a week to google this out, but it's working like charm now... I don't think there is another solution by godaddy accounts, the possibilities are too limited by them...

我花了大约一个星期的时间来搜索这个,但它现在就像魅力一样工作......我认为godaddy帐户没有另一个解决方案,可能性太有限了......

回答by sagesolutions

I found another useful guide to install git on GoDaddy at http://www.612softwarefoundry.com/getting-git-on-godaddy/

我在http://www.612softwarefoundry.com/getting-git-on-godaddy/上找到了另一个在 GoDaddy 上安装 git 的有用指南

回答by Yves A Martin

I had to set up git on a VPS hosted at http://netgonian.com(GoDaddy reseller). What took 3 hours could have been done in about 15 minutes and super easy.

我必须在http://netgonian.com(GoDaddy 经销商)上托管的 VPS 上设置 git 。花费 3 小时的时间本可以在大约 15 分钟内完成,而且非常简单。

Installing git should be as simple as running yum install gitbut unfortunately trying that gave me all sorts of could not find file errors. Below was the final solution.

安装 git 应该像运行一样简单,yum install git但不幸的是尝试给我带来了各种找不到文件的错误。下面是最终的解决方案。

Here are the steps:

以下是步骤:

  1. ssh onto your virtual server
  2. change over to the root user using the command su -
  3. follow the instructions here to create a new centos-base.repo file
  4. in the same directory where you just created the above file (/etc/yum.repos.d) rename the file CentoOS-Base.repo to CentOS-Base.repox
  5. now you can run yum install gitand it will work.
  1. ssh 到你的虚拟服务器
  2. 使用命令切换到 root 用户 su -
  3. 按照此处的说明创建新的 centos-base.repo 文件
  4. 在您刚刚创建上述文件(/etc/yum.repos.d)的同一目录中,将文件 CentoOS-Base.repo 重命名为 CentOS-Base.repox
  5. 现在你可以运行yum install git,它会工作。

The basic issue was that all the base urls for yum were pointing to some server on the secureserver.net that was missing all the needed files. What we are doing above is pointing the base urls to servers that have the needed files.

基本问题是 yum 的所有基本 url 都指向 secureserver.net 上的某个服务器,该服务器缺少所有需要的文件。我们上面所做的是将基本 url 指向具有所需文件的服务器。

回答by DrupalFever

There is a YouTube tutorial explaining how to set up Git on a Godaddy Shared Hosting account. Here is the link: http://youtu.be/z60GLfsGGsY

有一个 YouTube 教程解释了如何在 Godaddy 共享主机帐户上设置 Git。这是链接:http: //youtu.be/z60GLfsGGsY

There is also a webpage with the commands that you will need to execute on the video. Here is the page address: http://www.drupalfever.com/linux-how-to/git/set-up-git-in-a-godaddy-shared-hosting-account

还有一个网页,其中包含您需要在视频上执行的命令。这里是页面地址:http: //www.drupalfever.com/linux-how-to/git/set-up-git-in-a-godaddy-shared-hosting-account

If you have any question, leave me a note or suggestion.

如果您有任何问题,请给我留言或建议。

回答by justis

The instructions in this blog post worked for me, except that I had to visit EPEL and find the newest version of the git RPM: http://hire.chrisjlee.net/node/139

这篇博文中的说明对我有用,只是我必须访问 EPEL 并找到最新版本的 git RPM:http: //hire.chrisjlee.net/node/139

Fetch the binaries

获取二进制文件

cd ~
mkdir git
cd git
# Download the rpm from EPEL ( http://fedoraproject.org/wiki/EPEL )
# Find the latest version by checking http://dl.fedoraproject.org/pub/epel/5/i386/
wget http://dl.fedoraproject.org/pub/epel/5/i386/git-1.8.2.1-1.el5.i386.rpm
# Extract binaries from the rpm
rpm2cpio git-1.7.4.1-1.el5.i386.rpm  | cpio -imdv
rm git-1.7.4.1-1.el5.i386.rpm

Configure

配置

echo "
export GIT_BIN=${HOME}/git
export PATH=${GIT_BIN}/usr/bin:${PATH}
export GIT_EXEC_PATH=${GIT_BIN}/usr/bin
export GIT_TEMPLATE_DIR=${GIT_BIN}/usr/share/git-core/templates
export GIT_SSL_NO_VERIFY=true" >> ~/.bashrc

Configure git

配置git

mkdir ~/.git
git config --local --add remote.origin.uploadpack ~/git/usr/bin/git-upload-pack
git config --local --add remote.origin.receivepack ~/git/usr/bin/git-receive-pack