我从个人git服务器克隆了一个空的存储库.在初始push(push -u origin master)后我得到了一些错误,但我推进了内部.
尝试使用git push显示以下内容:
没有共同的参考,没有指定; 什么也不做.也许你应该指定一个分支,比如'master'.致命:远程端意外挂起错误:未能将某些引用推送到"link-top-repository"
然后我尝试了git push origin master:
Counting objects: 3, done.
Writing objects: 100% (3/3), 218 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
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'.
Run Code Online (Sandbox Code Playgroud)
使用时问题开始git pull:
您的配置指定与远程的ref'master'合并,但是没有获取此类ref.
我试着检查.git/config但似乎是正确的.
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = junior@54blue.com:/repository/regulator
[branch "master"]
remote = origin
merge = refs/heads/master
[branc "master"]
remote = origin
Run Code Online (Sandbox Code Playgroud)
有什么建议?
假设您具有对个人git服务器的写访问权限,您正在做的是将更改推送到非裸存储库,以及当前检出为工作目录的分支.
当前的常见良好实践总是推向裸存储库.要创建它,您可以执行以下操作:
git init --bare SomeRepo.git
Run Code Online (Sandbox Code Playgroud)
如果您坚持要推送到非裸存储库,这是不推荐的,请确保您要推送到的分支不是当前签出的分支或当前工作目录.只需打开命令行工具,例如Linux中的终端或windows中的git bash,移动到您的存储库目录(其中包含文件夹.git的目录),执行以下命令:
git branch -v
Run Code Online (Sandbox Code Playgroud)
它将显示该存储库的所有可用分支,并且当前签出的分支标有"*",例如:
* master b0bb0b1 some commit message
development babbab2 some other commit message
experimental bebbeb3 some commit message in experiment
Run Code Online (Sandbox Code Playgroud)
上面的示例显示master是当前签出的分支,因此您无法推送它.但你可以推动其他分支,如开发或实验.如果必须推送到master,可以使用以下命令将当前目录更改为其他分支:
git checkout the_branch_name
Run Code Online (Sandbox Code Playgroud)
在此之后,当前签出的是上面命令中指定的分支,现在可以推送到master.
| 归档时间: |
|
| 查看次数: |
14441 次 |
| 最近记录: |