将文件推送到git [duplicate]中的unc路径(远程)

问题描述 投票:1回答:1

我在UNC路径上有我的PC和远程文件夹(让我们说*\\10.30.1.15\GitRepositories\MyApp*)。

我已经在我的PC和遥控器中安装了Git。我所做的是在UNC路径和git init上运行C:/GitRepositories/MyApp

现在我在C:/GitRepositories/MyApp处添加一个文件并运行以下命令。

git add .
git commit -m 'initial commit'
git remote add origin \\10.30.1.15\GitRepositories\MyApp

现在,当我运行git push origin master时,我得到:

C:\GitRepositories\MyApp>git push origin master
fatal: '\10.30.1.15\GitRepositories\MyApp.git' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

UNC路径可供所有用户访问。暂时与所有人共享。

更新:我现在通过转义来更新路径路径之后,

C:\....>git init
Initialized empty Git repository in C:/..../.git/

C:\....>git remote add origin \\\\10.30.1.15\\GitRepositories\\MyApp

C:\....>git add .

C:\....>git commit -m 'intial'
[master (root-commit) 6870ea2] 'intial'
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test.txt

C:\....>git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 207 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
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 \\\\10.30.1.15\\\\GitRepositories\\MyApp
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '\\\\10.30.1.15\\GitRepositories\\MyApp'

如何避免这些错误消息?

git
1个回答
1
投票

尝试转义:

 git remote add origin \\\\10.30.1.15\\GitRepositories\\MyApp

或使用/:

 git remote add origin //10.30.1.15/GitRepositories/MyApp
 # or
 git remote add origin file:///10.30.1.15/GitRepositories/MyApp

关于第二个错误(在[GIT clone repo across local file system in windows中解决了not))考虑了远程存储库的性质:您需要一个bare repo。或者您需要从Git 2.3开始在该远程仓库上进行设置:

git config receive.denyCurrentBranch updateInstead

请参见“ push to deploy”。

另请参见“ Git Fetch Error with UNC”,Git 2.24(2019年第四季度)现在将授权:

git remote add origin file://10.30.1.15/GitRepositories/MyApp
© www.soinside.com 2019 - 2024. All rights reserved.