我有几个Windows计算机作为开发环境c:\projects\pyj
和一个ubuntu服务器/root/pyj
作为部署计算机。 Github和bitbuckets都不是我的选择,因为我想在我自己的服务器上构建git。
借助Windows软件,我可以在Windows计算机之间同步pyj
。但是我应该如何在每个窗口计算机和服务器之间同步pyj
?
我已经在windows和我的服务器上成功设置了ssh密钥,并使用git init --bare
创建了一个远程资源库。当我在Windows中git push -u origin -all
时,没有任何源文件推送到服务器。这不是我想要的。
所以我删除origin
并创建另一个远程仓库pyj
并在服务器中尝试git init
,但遇到这个:
$ git remote add pyj root@wdksw.com:/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 root@wdksw.com:/root/pyj/.git/
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'root@wdksw.com:/root/pyj/.git/'
那么,我应该如何使用git来满足我的需求?
答案 0 :(得分:2)
在v2.3.0之后,git添加了“push to deploy”功能。
在偏远地区。
git config --get receive.denyCurrentBranch
git config receive.denyCurrentBranch updateInstead
git config --get receive.denyCurrentBranch
通过此设置,当您在客户端推送时,将更新远程工作树。
有关详细信息,请参阅releasenote of v2.3.0