git 工作流 laptop-desktop-github

标签 git

我想要以下 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/

相关文章:

git pull 错误: "fatal: cannot rebase with locally recorded submodule modifications"

git - 如何列出 git 存储库中的所有文本(非二进制)文件?

git - 我可以使用自定义标志扩展 git 命令吗?

git - 如何在 TortoiseGit 中查看当前的 .ignore 列表?

.net - .NET 开发人员的 Git 与 Mercurial?

windows - 从 github 克隆存储库失败

android - 使用 JitPack 在 Gradle 中加载库

Git别名为新分支的名称添加前缀

git - 如何使用 diff 创建 .patch 文件并将其正确应用到单个 .cpp 文件?

ios - Xcode 11 SPM 身份验证失败,因为未提供凭据