【问题标题】:GIT repository across local file system in windowsWindows中跨本地文件系统的GIT存储库
【发布时间】:2015-08-23 19:10:09
【问题描述】:

我的计算机上已经有一个 Git 存储库。我想在我的计算机中为此设置一个远程存储库,例如在/path/to/remote
所以我使用git init来启动一个空的存储库。然后我使用了这个命令:

$ git remote add test "file:///path/to/remote/.git/"

然后尝试:

$ git push -u test --all

但这会导致错误:

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'.
To file:///path/to/remote/.git/
 ! [remote rejected] master -> master (branch is currently checked out)

我该如何解决这个问题?

编辑:

作为this question 提议的答案,我尝试推送到非签出分支并解决了问题。

【问题讨论】:

标签: git repository git-push


【解决方案1】:

确保远程存储库是存储库

git init --bare

那你就可以推送了

git push -u file:///path/to/remote/ --all

【讨论】:

  • 谢谢,但我不想推送到没有工作目录的存储库。
  • 好吧,如果你真的不想要一个裸存储库并且确实想要推送,那么遵循警告“将'receive.denyCurrentBranch'配置变量设置为'忽略'或'警告'在远程存储库以允许推送到其当前分支;但是,除非您安排更新其工作树以匹配您以其他方式推送的内容,否则不建议这样做。"
猜你喜欢
  • 2011-01-31
  • 1970-01-01
  • 2016-04-03
  • 2020-10-31
  • 2012-06-05
  • 2014-06-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多