推送到 git 存储库不起作用 [英] pushing to a git repository does not work

查看:28
本文介绍了推送到 git 存储库不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 GIT(我来自 cvs)并且想用 Git 设置类似于 cvs/svn 的东西.我执行了以下步骤:

I am just starting out with GIT (i'm coming from cvs) and would like to set up something akin to cvs/svn with Git. I performed the following steps:

cd o:/repository
git init

cd <working directory>
git clone o:/repository

我现在创建了一个名为 file.txt 的文件,其中包含一些内容执行git status"列出适当的更改.

i now created a file called file.txt with some content doing a "git status" lists appropriate changes.

然后我做

git add file.txt
git commit file.txt

两者似乎都运行良好.

当我这样做时git push,我收到以下错误:

When i do git push, i get the following error:

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'o:/repository'

我尝试先执行拉取操作,并指定推送命令的原点和主变体,但均无效.

I tried doing a pull first, as well as specifying origin and master variations to the push command but none work.

谁能告诉我我错过了什么.我运行的是 Windows 7 64 位.

Can someone please tell me what i am missing. I am running Windows 7 64 bit.

附言.我也试过

git push origin master

我得到以下信息:

Counting objects: 3, done.
Writing objects: 100% (3/3), 251 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To O:/repository
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'O:/repository'

推荐答案

这发生在我们几周前.这意味着您在源存储库中签出了一个工作目录,并且您无法推送覆盖.

This happened to us a few weeks ago. It means that you have a working directory checked out in your origin repository and you cannot push to overwrite.

在原点,您需要裸露存储库.我不知道用一个命令来完成它的方法.我做了什么(在原始存储库中)

at the origin you need to bare the repository. I don't know of a way to do it with one command. What I did (at the origin repository)

> mv repository repository.old
> git clone --bare repository.old repository

我看到您的案例的来源是 o:/repository.原点不应是已检出的工作副本,因此您可以按照上述方法初始化裸存储库或副本.要使您描述的场景通过:

I see that the origin in your case is the o:/repository. The origin, should not be a checked out working copy, so you can init a bare repository or copy as per above. To get the scenario you described to pass:

cd o:/repository
git init  --bare

cd <working directory>
git clone o:/repository

git push origin master

这应该适合你:

好读物:http:///www.gitready.com/advanced/2009/02/01/push-to-only-bare-repositories.html

这篇关于推送到 git 存储库不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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