如何使用git创建远程仓库(供局域网多人使用)

用git init(默认创建的是私人的仓库)创建的仓库,推送是不会成功的。

因此在git server端,我们要用 git --bare init --shared=group 来创建一个bare库,意思是创建一个共享的多人合作的仓库,这样则可以往新建的远程仓库中推送更新。

 

在git client 端,可以用如下命令对远程仓库进行跟踪:

git clone ssh://192.168.100.103/~/jj/.git

在有改动的情况下,可以使用:

git push origin master,   将本地master分支push到远端的master分支

 

注意,远程仓库必须是bare库,若为非bare库,则不能提交,会提示:

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'.

posted @ 2016-04-11 10:28  微信公众号--共鸣圈  阅读(2059)  评论(0编辑  收藏  举报