简体   繁体   English

尝试将现有 git 项目上传到 gitlab 时,如何解决“预接收挂钩被拒绝”错误?

[英]How to fix the "pre-receive hook declined" error when trying to upload an existing git project to gitlab?

Our project was developed by another external company and hosted in their respective gitlab account.我们的项目由另一家外部公司开发并托管在他们各自的 gitlab 帐户中。

Now they have passed us the source code and we want to upload it to our gitlab account.现在他们已将源代码传递给我们,我们想将其上传到我们的 gitlab 帐户。 We have created a private repository in gitlab for this.为此,我们在 gitlab 中创建了一个私有存储库。 This repository only has the admin user and is empty.此存储库只有管理员用户并且是空的。

However, when doing git push origin master it gives us the following error:但是,在执行git push origin master时,会出现以下错误:

[remote rejected] master -> master (pre-receive hook declined)
error: some references to 'gitlab.com:sanduzelai/xxx.git' failed to push

How can we fix this error?我们如何解决这个错误?

I've read similar questions on stackoverflow but haven't gotten it to work.我已经阅读了关于 stackoverflow 的类似问题,但还没有让它发挥作用。 I have tried creating a branch from master and doing git push but it has not worked.我曾尝试从 master 创建一个分支并执行git push ,但它没有奏效。 If I delete the .git folder and create it with the git init command the repository is successfully uploaded to gitlab.如果我删除.git文件夹并使用git init命令创建它,则存储库已成功上传到 gitlab。 However, I would like to keep the logs.但是,我想保留日志。 Is this possible?这可能吗?

Thanks in advance提前致谢

You might consider if the external company will "transfer" the project to you instead of a download/upload like what's being done, as that would preserve not only the repository history, but also any open issues on the project.您可能会考虑外部公司是否会将项目“转移”给您,而不是像正在做的那样下载/上传,因为这不仅会保留存储库历史记录,还会保留项目中的任何未解决问题。 If they (or you) run a self-hosted gitlab, you can also export and import the project to get the same approach.如果他们(或您)运行自托管 gitlab,您还可以导出和导入项目以获得相同的方法。

That having been said, there are multiple things that can cause this type of an issue, but here are a couple of examples:话虽如此,有多种因素可能导致此类问题,但这里有几个示例:

  • If you're running a self-hosted gitlab, you may have server-side git hooks that are blocking the commit.如果您正在运行自托管 gitlab,您可能有阻止提交的服务器端 git 挂钩。
  • If you're running on gitlab.com, you may have rules enabled that force a certain email to be used for pushing a commit, or you may require GPG signing of commits如果您在 gitlab.com 上运行,您可能启用了强制某个 email 用于推送提交的规则,或者您可能需要提交的 GPG 签名

You should likely send a note to your gitlab admin and determine what your setup is, and what may be blocking the commit.您可能应该向您的 gitlab 管理员发送一条说明,并确定您的设置是什么,以及什么可能阻止提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM