今天试用试用HTTP的方式搭一个git repository server,但是最后无法push,提示
error: Cannot access URL http://xxxx/experience.git/, return code 22
fatal: git-http-push failed
最后只好放弃,改用SSH方式, 先初始化git仓库:
$ mkdir myproject.git
$ cd myproject.git
$ git init --bare
这里需要注意--bare参数,表示是要生成一个"干净"的仓库,仅包含历史代码不包含工作代码。如果是希望初始化一个已存在的代码库,也可以类似如下命令替换最后一行git命令:
但是第一次commit时,出现
[frankwang@apollo-2 test2]$ git push
frank@xxxxx's password:
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'ssh://frank@xxxx/home/frank/test2.git'
网上查了以下,解决方法如下:
http://blog.csdn.net/viweei/article/details/6163562
http://www.thebuzzmedia.com/git-tip-git-push-no-refs-in-common-and-none-specified/
$ git push origin master
[frankwang@apollo-2 test2]$ git push origin master
frank@192.168.1.135's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 213 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://frank@xxx/home/frank/test2.git
* [new branch] master -> master