我想要以下 git 工作流程,
github
/ \
laptop-----desktop
想法是台式机与笔记本电脑保持同步,并且无论何时从任何一台计算机推送到 github。
由于我的笔记本电脑不是永久在线的,我需要一种从笔记本电脑 pull 和推送到桌面的方法。在笔记本电脑上,我克隆了 github 存储库,然后为桌面制作了一个 Remote 。然后我设置了一个跟踪分支(在笔记本电脑上)来跟踪桌面上的“开发”分支。
> git branch --track develop desktop/develop
我对笔记本电脑上的“开发”分支进行了更改,提交并尝试推送到我得到的桌面。
>git push desktop
...
remote: error: refusing to update checked out branch: refs/heads/develop
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'.
To ssh:// ....
! [remote rejected] develop -> develop (branch is currently checked out)
我阅读了一些有关该错误的信息,这听起来像是推荐的做法是从桌面上 pull ,而不是从笔记本电脑上推送,但这不是一个选项。
最佳答案
git 告诉您正确的操作:您可以在远程存储库中将 receive.denyCurrentBranch
配置变量设置为“忽略”或“警告”以允许推送到
它当前的分支。
关于git 工作流 laptop-desktop-github,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9150282/