我有一个使用git进行版本控制的项目。
我想要做的就是在我的(启用了ssh的)GoDaddy共享托pipe软件包上build立一个回购站点,这样我就可以通过推送来进行部署,而不用在FTP中拖放。
任何提示将不胜感激。 最好的办法是从已经完成的人那里得到一个帐户,但是我无法亲自在网上find任何信息。
我遇到了与HostNine共享托pipe软件包托pipe的网站相同的问题。 他们也给你ssh访问,但不幸的是没有安装git ,甚至没有给你访问运行gcc ,使其相当难以为你的用户下载和安装git。
我能想到解决这些限制的唯一方法就是从另一台拥有它们的计算机上复制git二进制文件。 也许同样的解决scheme可以为你和你的GoDaddy共享主机工作。 以下是我所做的:
首先找出你的服务器有什么架构。 在我的情况下,它是32位(i386)。 这里有几个方法来解决这个问题:
# uname -a Linux ___.myserverhosts.com 2.6.18-128.1.6.el5PAE #1 SMP Wed Apr 1 10:02:22 EDT 2009 i686 i686 i386 GNU/Linux # file /bin/echo /bin/echo: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
接下来,您需要find另一台运行Linux的计算机,并使用相同的体系结构并安装git。 他们甚至不必运行相同的发行版或Linux版本,只要它们是相同的体系结构,并且可以find所需的二进制文件和库文件。
要find主要的git二进制文件的位置:
> which git /usr/local/bin/git
其他一些重要的二进制文件(如git-receive-pack )也驻留在同一个目录中,所以我build议只复制/usr/local/bin/git*以确保获得所需的所有内容。
git依赖的其他重要文件位于源系统某处的“libexec”目录下。 如果你不复制这些,你可能会遇到一个令人惊讶的错误消息,当你尝试做一个git push ,就像我做的那样:
git: 'index-pack' is not a git-command. See 'git --help'.
要在target_host上find包含核心git库的目录,可以使用以下命令:
> git --exec-path /usr/local/libexec/git-core
我build议首先复制这些文件,然后尝试运行git来查看它是否抱怨任何缺less的共享库。 如果没有,那么你(大概)是好的去。 如果有,请继续阅读。 (如果共享库已经存在于目标主机上且是正确的版本,则不要使用共享库进行复制。)
您可以使用scp , rsync , ftp或任何您scp的文件复制这些文件。 我用scp ,像这样:
> ssh target_host 'mkdir -p ~/bin ~/libexec' > scp /usr/local/bin/git* target_host:~/bin > scp -r /usr/local/libexec/git-core target_host:~/libexec
然后ssh到target_host。 你需要在~/.bashrc添加这样的行:
export PATH=$PATH:~/bin export LD_LIBRARY_PATH=~/lib export GIT_EXEC_PATH=~/libexec/git-core
如果你忘了这一步,你可能会惊讶地看到这个错误,当你做一个git push :
git-receive-pack: command not found
这在git.or.cz的Git FAQ上有logging:
基本上问题是'git-receive-pack'不在远程端的默认$ PATH中。
…
- 确保在
.bashrc设置了正确的path(不仅是.bash_profile)
GIT_EXEC_PATHlogging在man git :
--exec-path Path to wherever your core git programs are installed. This can also be controlled by setting the GIT_EXEC_PATH environment variable. If no path is given, git will print the current setting and then exit.
源你的新的~/.bashrc 。 现在尝试运行git 。
这是它第一次给了我:
> git git: error while loading shared libraries: libcrypto.so.4: cannot open shared object file: No such file or directory
通过在源计算机上运行,我能够找出要复制的共享库的位置:
> ldd /usr/local/bin/git libz.so.1 => /usr/lib/libz.so.1 (0xb7fcf000) libcrypto.so.4 => /lib/libcrypto.so.4 (0xb7ee4000) libpthread.so.0 => /lib/tls/libpthread.so.0 (0xb7ed2000) libc.so.6 => /lib/tls/libc.so.6 (0xb7da6000) libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0xb7d92000) libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0xb7d2d000) libcom_err.so.2 => /lib/libcom_err.so.2 (0xb7d2a000) libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0xb7d08000) libresolv.so.2 => /lib/libresolv.so.2 (0xb7cf5000) libdl.so.2 => /lib/libdl.so.2 (0xb7cf1000) /lib/ld-linux.so.2 (0xb7fe8000)
在我的情况下,我只需要将/lib/libcrypto.so.4复制到我的target_host上的~/lib ,一切都很好。
现在你应该在你的共享主机服务器上有一个可用的git ,你应该可以推送到它!
现在,您需要在服务器上创build一个新的git存储库和工作树,或者复制现有的存储库/工作树。
顺便说一下,在这种情况下,我不认为在服务器上是一个裸仓库,因为你说你想部署实际的内容文件(而不是只config HEAD objects/ refs/将包含的config HEAD objects/ refs/ files在裸仓库中),每当你做一个git push 。
toolmantim.com解释了常规git存储库和裸存储库之间的区别:
一个默认的git仓库假设你将使用它作为你的工作目录,所以git将实际裸仓库文件和所有项目文件一起存储在.git目录中。 远程仓库不像工作副本那样需要文件系统上文件的副本,他们所需要的只是仓库本身的增量和二进制文件。 这就是“裸”的意思。 只是存储库本身。
我暂时假设你已经在你的target_host上创build了一个你想部署你的网站的目录(或者你正在部署的任何东西)。 我们调用这个目录~/www/my_site 。 你甚至可能已经把所有的文件~/www/my_site already到了~/www/my_site already 。 (不pipe你有没有不重要)。我现在还假定你还没有将.git子目录复制到~/www/my_site (如果你有的话,它应该可以正常工作)。
由于还没有在target_host上初始化一个git仓库,所以你的第一步就是创build一个:
> cd ~/www/my_site > git init
然后,从任何主机拥有您想要部署的最新更改的存储库(您的开发框,我猜),您只需要这样做部署:
> git push --all ssh://username@target_host:port/~/www/my_site/.git
如果target_host上的存储库尚未更新,则可能会看到如下警告:
> warning: updating the current branch > warning: Updating the currently checked out branch may cause confusion, > warning: as the index and work tree do not reflect changes that are in HEAD. > warning: As a result, you may see the changes you just pushed into it > warning: reverted when you run 'git diff' over there, and you may want > warning: to run 'git reset --hard' before starting to work to recover. > warning: > warning: You can set 'receive.denyCurrentBranch' configuration variable to > warning: 'refuse' in the remote repository to forbid pushing into its > warning: current branch. > warning: To allow pushing into the current branch, you can set it to 'ignore'; > warning: but this is not recommended unless you arranged to update its work > warning: tree to match what you pushed in some other way. > warning: > warning: To squelch this message, you can set it to 'warn'. > warning: > warning: Note that the default will change in a future version of git > warning: to refuse updating the current branch unless you have the > warning: configuration variable set to either 'ignore' or 'warn'.
(在正常的git用法中,我认为你从来没有看到这个消息,因为你通常会推送到裸仓库,但是由于在这种情况下,远程仓库是一个普通的仓库,同时有一个工作树和一个索引,所以git可以理解地担心它可能会搞砸了。)
不过,我认为将它设置为在服务器上“忽略”是安全的,因为您不太可能直接向存储库提交任何提交。 (所有的提交应该可能来源于你的开发仓库,然后被推送到服务器。)
因此,请继续设置,这样每次按下时都不会看到警告:
> ssh target_host 'cd ~/www/my_site/; git config receive.denyCurrentBranch ignore'
push本身只会更新索引,但不是工作树本身的文件。 但是,更新这些文件只是我们要做的全部工作,所以我们的工作不会完成,直到我们告诉git将索引的内容写入工作树本身,如下所示:
> ssh target_host 'cd ~/www/my_site/; git reset --hard'
(注意:您在服务器上的工作树中所做的任何更改都将被存储库中的内容覆盖)。
我也遵循mattikus的build议,并为我的服务器创build一个远程:
> git remote add h9 ssh://username@target_host:port/~/www/my_site/.git
所以现在我要做的部署是:
> git push --all --force h9 > ssh remote_host 'cd ~/www/my_site/; git reset --hard'
我甚至竟然把这些命令放在一个脚本中,我命名为script/deploy所以任何时候我想部署我只有一个命令来运行。
如果您在这些说明中发现任何错误,或者您知道更好的解决scheme,请告诉我们。
我既是SF又是godaddy,所以请忍受我,但无论如何,我很高兴看到这里讨论这个。
只有我的$ 0.02,我试图在我的Linux机器上dynamic地构buildgit,把它放到我的godaddy帐户上,即使只是试图推送到被动的godaddy机器,它也会因为缺lessopenssl而失败。 也许如果我试图用openssl静态地构buildgit,但是它也是一个糟糕的主意。
$ git remote add godaddy ssh://[email protected]//home/content/u/n/c/unclecj/foo.git $ git push godaddy master bash: git-receive-pack: command not found fatal: The remote end hung up unexpectedly $ git push --receive-pack="/home/content/u/n/c/unclecj/opt/git-1.6.3/bin/git-receive-pack" godaddy master /home/content/u/n/c/unclecj/opt/git-1.6.3/bin/git-receive-pack: error while loading shared libraries: libcrypto.so.0.9.8: cannot open shared object file: No such file or directory fatal: The remote end hung up unexpectedly
偏离话题,但是这是我应该从godaddy期待的那种缺乏支持,我是否应该后悔不selectdreamhosts?
最好的问候CJ
PS。 不是一个答案,而是一个build议,一旦git-receive在godaddy上工作(是吗?),那么一个具有分离工作树的仓库是一个很好的方式来部署网站: http ://toroid.org/ams/git- 网站-HOWTO
最简单的方法是在远程服务器上运行这样的东西:
mkdir repo.git cd repo.git git init --bare
然后在你的开发结账:
git push --all ssh://<username>@<your server>/~/path/to/repo/relative/to/homedir/repo.git
没有服务器或其他任何需要的东西,只要你有ssh访问权限,你应该能够从那台机器上取/拉。
如果你的.ssh / config也设置好了,它应该利用它并使用你可能设置的任何私钥。
如果你打算推出更新,你可以添加一个远程repo到你的devel checkout:
git remote add godaddy ssh://<username>@<your server>/path/to/repo.git
那么从那时起你可以:
git push godaddy
有关更多信息,请查看关于git push的在线文档,或运行git push --help启动本地手册页。