gpt4 book ai didi

Git pull 和推不起作用

转载 作者:太空狗 更新时间:2023-10-29 13:56:35 25 4
gpt4 key购买 nike

我从个人 git 服务器克隆了一个空存储库。初始推送后 (push -u origin master) 我遇到了一些错误,但我推送了进去。

尝试使用 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 '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'.

使用 git pull 时出现问题:

Your configuration specifies to merge with the ref 'master' from the remote, but no such ref was fetched.

我试着检查 .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

有什么建议吗?

最佳答案

假设您对您的个人 git 服务器具有写入权限,您正在做的是将更改推送到 non-bare repository ,以及当前 check out 为工作目录的分支。

当前常见的良好做法始终是推送到裸存储库。要创建它,您可以这样做:

git init --bare SomeRepo.git

如果你坚持推送到一个非裸仓库(不推荐),请确保你要推送到的分支不是当前 checkout 的分支或当前工作目录。只需打开命令行工具,例如 Linux 中的终端或 Windows 中的 git bash,移动到您的存储库目录(其中包含文件夹 .git 的目录),执行此命令:

git branch -v

它会显示该版本库的所有可用分支,当前 checkout 的分支用'*'标记,例如:

* master        b0bb0b1 some commit message
development babbab2 some other commit message
experimental bebbeb3 some commit message in experiment

上面的例子显示 master 是当前 checkout 的分支,因此你不能推送到它。但是您可以 push 其他分支,例如开发或实验。如果必须推送到 master,可以通过使用以下命令将当前目录更改为其他分支来完成:

git checkout the_branch_name

此后,当前 check out 的是上面命令指定的分支,现在可以推送到master了。

关于Git pull 和推不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13746606/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com