Windows 中跨本地文件系统的 GIT 存储库

has*_*ian 0 git repository git-push

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

$ git remote add test "file:///path/to/remote/.git/"
Run Code Online (Sandbox Code Playgroud)

然后尝试:

$ git push -u test --all
Run Code Online (Sandbox Code Playgroud)

但结果错误:

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)
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

编辑:

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

Ham*_*bad 6

确保远程仓库是仓库

git init --bare
Run Code Online (Sandbox Code Playgroud)

然后你可以推到它

git push -u file:///path/to/remote/ --all
Run Code Online (Sandbox Code Playgroud)