推动和现有项目进入裸回购 [英] Pushing and existing project into bare repo

查看:89
本文介绍了推动和现有项目进入裸回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用git和laravel在本地开发一个项目。我终于决定为我们的服务器添加一个裸回购,以便推动更改和自动化部署。



我确定我做错了,因为我绿色使用GIT。当我做推时,我得到以下错误:

  stdin:不是tty 
bash:git-receive -pack:找不到命令
致命:无法从远程存储库读取

请确保您拥有正确的访问权限并存在存储库。

这是我使用的过程 - 记住项目资源库最初是从laravel克隆的,并且我创建了我的自己的主分支和一些推动存在。我已经有了所有ssh日志记录设置。


  1. 通过ssh登录

  2. 创建的目录: mkdir public_html.git

  3. 更改目录: cd public_html.git

  4. 创建了回购: git init --bare

  5. 添加了post-receive钩子 - 哪个i已验证在测试项目中工作

  6. 移回本地机器

  7. 添加新的远程机器: git remote add www user @ 0.0.0.0:public_html.git

  8. 创建了一个新分支: git checkout -b开发

  9. 尝试推送: git push www



<大部分的研究都是从检查git / config文件中提到的,但所有这些似乎都是正确的。

解决方案

<看起来像 git-receive-pack 不在用于推送到存储库的用户配置的路径上。当你通过SSH推送到git仓库时,git将使用ssh在推送的用户帐户下执行远程服务器上的命令。这些命令(例如 git-receive-pack )必须在服务器上该用户的路径上可用。为了诊断这一点,我将开始执行命令

  ssh user@0.0.0.0哪个git-receive-pack 

您几乎肯定会得到一个未找到命令的错误。接下来,您可以尝试

  ssh user@0.0.0.0'echo $ path'#请注意单引号。 

这会告诉你用户的路径在远程服务器上,并且可以帮助你找出什么是错误。请注意ssh手册页中的行:


... [user @] hostname [command]



...



如果指定了命令,它将在远程主机上执行,而不是在登录shell中执行。


这可能是一个微妙而重要的区别,因为它意味着用 ssh user@0.0.0.0 创建的远程登录shell。 code>可能看不到与 ssh user@0.0.0.0某些远程命令运行的命令相同的shell环境。 这个答案解释了如何在bash shell中工作,其他人的行为类似。


I've been working on a project locally using git and laravel. I've finally decided to add a bare repo to our server in order to push the changes and automate deployment.

I'm sure I'm doing something wrong as I'm green to using git. When I do a push I get the following error:

stdin: is not a tty
bash: git-receive-pack: command not found
fatal: Could not read from remote repository

Please make sure you have the correct access rights and the repository exists.

Here's the process I used - keep in mind the project repository was initially cloned from laravel and I created my own master branch and a few pushes exist. I also have all ssh logging setup already.

  1. logged in via ssh
  2. created directory: mkdir public_html.git
  3. changed directory: cd public_html.git
  4. created the repo: git init --bare
  5. added a post-receive hook - which i verified works in a test project
  6. moved back to local machine
  7. added a new remote: git remote add www user@0.0.0.0:public_html.git
  8. made a new branch: git checkout -b develop
  9. attempted to push: git push www

Most of the research from looking into this mentions checking the git/config file, but all of that seems to be correct.

解决方案

It looks like git-receive-pack is not on the path for the user configuration used to push to the repository. When you push to a git repository via ssh git will use ssh to execute commands on the remote server under the user account which is doing the push. These commands, such as git-receive-pack, must be available on that user's path on the server. To diagnose this I would start by executing the command

ssh user@0.0.0.0 which git-receive-pack

You will almost certainly get a command not found error. Next you could try

ssh user@0.0.0.0 'echo $path' # Note the single quotes.

This will show you what the user's path is on the remote server and may help you figure out what is wrong. Note the line in the ssh man page:

ssh ... [user@]hostname [command]

...

If command is specified, it is executed on the remote host instead of a login shell.

This can be a subtle but important distinction as it means a login shell to the remote created with ssh user@0.0.0.0 may not see the same shell environment as a command run by ssh user@0.0.0.0 some remote command. This answer has an explanation of how this works for the bash shell, others behave similarly.

这篇关于推动和现有项目进入裸回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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