
我有2台機器,客戶端和伺服器。我想使用遠端推送將 git 儲存庫從客戶端傳送到伺服器。我已在伺服器上按以下順序執行這些命令:
mkdir /mnt && cd /mnt
mkdir test.git && cd test.git
sudo git init --bare
我已在客戶端上執行這些命令:
mkdir /mnt && cd /mnt
mkdir test.git && cd test.git
sudo git init
sudo git remote add testy ssh://user@server/mnt/test.git
sudo vim testing.txt
sudo git add testing.txt
sudo git commit -m "testing"
sudo git push testy master
這會在客戶端電腦上產生錯誤:
fatal: '/mnt/test.git' does not appear to be a git repository. fatal: The remote end hung up unexpectedly.
有幾個類似的問題,但沒有一個能解決我的問題。我逐字嘗試了他們的解決方案,但沒有成功。這不是重複的,因為這些答案不能解決問題。有什麼建議來解決這些問題嗎?
答案1
我猜想user@server
沒有讀取/寫入/執行存取權限/mnt/test.git
:
$ sudo sh -c 'cd $(mktemp -d) && git init --bare'
Initialized empty Git repository in /tmp/tmp.TNLcXTZQcN/
$ cd $(mktemp -d)
$ git remote add /tmp/tmp.TNLcXTZQcN
fatal: Not a git repository (or any parent up to mount point /tmp)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).