git push 到远程主分支

标签 git

我有一个远程和一个本地 git 存储库。
本地存储库是从远程克隆的。
当我修改本地仓库并提交到 master 分支时。
然后我运行“git push”到远程存储库。
但它失败并输出以下消息。

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 t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
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 som
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

我在远程仓库中“git checkout -b current”另一个分支。
在我的本地存储库中,我运行“git push”然后它成功了。
但是本地修改只推送到远程master分支。
然后我应该在远程存储库中运行“git merge master”来进行更改。

我是 git 新手。
我做错了吗?

最佳答案

远程仓库不是一个裸仓库,并且已经被 master checkout 。而且,默认情况下,git 不允许您推送到非裸仓库的 checkout 分支。

理想情况下,您推送到的远程仓库应设置为裸仓库 (git init --bare)。

关于git push 到远程主分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11681080/

相关文章:

git - Atlassian Stash 中的差异分支

git - 执行 git stash 不会删除 git local 中的更改

git - 使用 gnu make 正确构建 git 子模块

css - 连续文件损坏包含 Django 元素的多个 GIT 存储库

git - "* text=auto"和 "* text=auto eol=lf"有什么区别?

git - IntelliJ VCS 日志窗口变空

R: Git + Shiny 服务器自动化部署

git - 如何获取 GitLab 项目分支中的最后一次提交状态?

android - 如何重置到我在 Android Studio 中的最后一次提交

Gitlab打不开目录