git推送到远程主分支
我有一个远程和一个本地git存储库。git推送到远程主分支,git,Git,我有一个远程和一个本地git存储库。 本地存储库是从远程克隆的。 当我修改本地存储库并提交到主分支时。 然后我运行“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: err
本地存储库是从远程克隆的。
当我修改本地存储库并提交到主分支时。
然后我运行“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'.
I“git checkout-b current”远程存储库中的另一个分支。在本地存储库中,我运行“git push”,然后it成功。
但是本地修改只推送到远程主分支。
然后,我应该在远程存储库中运行“git merge master”来接受更改 我是git的新手。
我做错了吗?远程存储库不是裸存储库,已签出master。而且,默认情况下,git不允许您推送到非裸回购的签出分支
理想情况下,您推送到的远程回购应该设置为裸回购(
git init--bare
)。当我刚加入github时,我的导师给了我以下经验法则:
在本地修改代码。提交时,请执行以下操作:
git pull
(将远程回购的内部引用头同步到本地存储库非常重要)git push
,保存您对首先要提交的代码所做的本地更改希望这有帮助 manojlds的回答是正确的,但是了解远程回购的目的可能会有所帮助
- 如果远程回购只是出于备份/协作目的->您的想法是正确的,只需将远程回购替换为“裸”回购即可
- 如果远程repo是生产服务器,那么您做错了->您应该有不同的配置
我相信有关于如何做到这一点的指南。。。我自己也有过这样一次:)可能与相同的重复,我认为这对OP没有帮助,因为你说的是slipslop将军,而不是他的问题。关于你的经验法则:我认为这是错误的。到了该提交的时候,提交。时期没有别的了。当是时候将事情放回到另一次回购中时,您必须执行类似于
提取
和重设基础
,拉取
或类似操作。然后解决冲突。然后按按钮
。在步骤3中,您的本地提交被发送到远程repo。SVN不是一件痛苦的事,它是一件痛苦的事。我现有的回购协议可以被设置为裸机回购(git-init--bare)吗?我不这么认为,但是如果它是一个基于linux的主机,并且你的回购协议名为“foo”,那么它就简单得像这样:mv-foo-foo-2
,mkdir-foo
,cd-foo
,git-init---bare
,git-remote-add-origin./../foo2
,git-pull