
我透過 root 在我的 vps 上建立了一個 git 儲存庫,並將其共享,以便一群人能夠存取它:
# mkdir example.git
# cd example.git
# git init --bare --shared=group
Initialized empty shared Git repository in /root/example.git/
# ls
branches config description HEAD hooks info objects refs
# chgrp -R devs .
然後,作為本地電腦上的用戶,我建立了一個目錄並添加了 example.git 作為此 git 儲存庫的新來源。最後我嘗試推動原點:
mkdir bubbles && cd bubbles
bubbles ranuka$ git init
Initialized empty Git repository in /Users/ranuka/Desktop/bubbles/.git/
bubbles ranuka$ ls
bubbles ranuka$ git remote add origin [email protected]:example.git
bubbles ranuka$ echo "Hello" > readme.txt
bubbles ranuka$ git add readme.txt
bubbles ranuka$ git commit -m "Adding a readme file"
[master (root-commit) 2c89e43] Adding a readme file
1 file changed, 1 insertion(+)
create mode 100644 readme.txt
bubbles ranuka$ git push origin master
[email protected]'s password:
fatal: 'example.git' does not appear to be a git repository
對此錯誤感到困惑,因為我知道 example.git 顯然是我的 vps 上的一個儲存庫。我以“ranuka”身份登入我的 vps 並嘗試 cd 到 example.git 但無法,但由於某種原因我可以作為 root .. 給出了什麼?
我的目標是在我的 vps 上建立一個 git 儲存庫,某個群組中的一群使用者可以存取並進行推送/拉取。
編輯:運行 ls -a 後[電子郵件受保護]和[電子郵件受保護] 結果如下:
. example.git
.. gitosis
ajenti-repo-1.0-1.noarch.rpm install.log
anaconda-ks.cfg install.log.syslog
.bash_history pgdg-centos93-9.3-1.noarch.rpm
.bash_logout .pki
.bash_profile repo.git
.bashrc .rnd
.cshrc .ssh
epel-release-6-8.noarch.rpm .tcshrc
和
. .. .bash_logout .bash_profile .bashrc
所以看起來 root 和 ranuka 位於不同的目錄中,沒有任何關係。
答案1
不同的使用者有不同的主資料夾。
如果您以 root 身分登錄,則主頁為/root
.
其他用戶將無法存取它。
如果您以 ranuka 身份登錄,則您的家(可能)是/home/ranuka
。
當然,其中不包含該資料夾,因為它位於/root
.