0
我有幾個Windows電腦作爲開發環境c:\projects\pyj
和一個Ubuntu服務器/root/pyj
作爲部署之一。 Github和bitbuckets都不是我的選擇,因爲我想在自己的服務器上構建git。如何用git在遠程服務器上設置一個同步目錄?
隨着Windows軟件的幫助下,我可以在Windows電腦之間同步pyj
。但是我應該如何在每個窗口計算機和服務器之間同步pyj
?
我已經成功地在Windows和我的服務器上設置了ssh密鑰,我用git init --bare
來創建遠程存儲庫。當我在Windows中輸入git push -u origin -all
時,沒有任何源文件被推送到服務器。這不是我想要的。
所以我刪除origin
,並創建另一個遠程回購pyj
,並嘗試在服務器git init
,但遇到這樣的:
$ git remote add pyj [email protected]:/root/pyj/.git/
$ git push -u pyj --all
Counting objects: 18, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (18/18), 4.43 KiB | 0 bytes/s, done.
Total 18 (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 inconsist ent
remote: error: with what you pushed, and will require 'git reset --hard' to matc h
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
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 som
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To [email protected]:/root/pyj/.git/
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '[email protected]:/root/pyj/.git/'
所以,我應該怎麼使用git,以滿足我的需要?
您需要服務器端的post-receive掛鉤。 – gzh