2016-09-26 39 views
1

我在UNC路徑上有我的PC和遠程文件夾(可以說*\\10.30.1.15\GitRepositories\MyApp*)。在git中將文件推送到unc路徑(遠程)

我在我的電腦和遠程都安裝了Git。
我所做的是在UNC路徑和C:/GitRepositories/MyApp上運行git init

現在我添加一個文件在C:/GitRepositories/MyApp並運行以下命令。

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

現在,當我運行混帳推起源主,我得到:

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' 

我怎樣才能避免這些錯誤消息?

+0

對於原來的問題(如何通過網絡共享執行此操作):[GIT克隆跨本地文件系統在Windows中的回購](http://stackoverflow.com/q/2519933/216074) – poke

回答

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」 尋址)關於遠程回購的性質:你需要一個bare repo
或者你需要,對遠程回購,因爲Git的2.3設置:

git config receive.denyCurrentBranch updateInstead 

請參閱 「push to deploy」。

+0

感謝作品,但我現在得到不同的錯誤。往上看。 – user960567

+0

@ user960567您需要在遠程回購端設置配置:請參閱我編輯的答案。 – VonC

+0

It works非常感謝 – user960567