推送到git存储库不起作用

Cod*_*der 8 versioning git version-control

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

cd o:/repository
git init

cd <working directory>
git clone o:/repository
Run Code Online (Sandbox Code Playgroud)

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

然后我做

git add file.txt
git commit file.txt
Run Code Online (Sandbox Code Playgroud)

两者似乎都很好.

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

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'
Run Code Online (Sandbox Code Playgroud)

我首先尝试执行pull,以及为push命令指定origin和master变量但是没有工作.

有人可以告诉我我错过了什么.我正在运行Windows 7 64位.

PS.我也试过了

git push origin master
Run Code Online (Sandbox Code Playgroud)

我得到以下内容:

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'
Run Code Online (Sandbox Code Playgroud)

Geo*_*tte 14

几周前发生在我们身上.这意味着您在原始存储库中检出了工作目录,并且无法进行覆盖.

在原点你需要裸露存储库.我不知道用一个命令做到这一点的方法.我做了什么(在原始存储库)

> mv repository repository.old
> git clone --bare repository.old repository
Run Code Online (Sandbox Code Playgroud)

我看到你的案例的起源是o:/ repository.原点不应该是签出的工作副本,因此您可以按照上面的方式初始化裸存储库或副本.要获得您描述的方案通过:

cd o:/repository
git init  --bare

cd <working directory>
git clone o:/repository

git push origin master
Run Code Online (Sandbox Code Playgroud)

这应该适合你:

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


Eli*_*lay 5

对于第一次推动,你需要类似的东西

git push origin master
Run Code Online (Sandbox Code Playgroud)

另请参见push.default选项选项.

在任何情况下,如果您以后遇到推送到非裸存储库的问题,那么您也需要阅读相关内容.