前言
今天把项目放到码云上进行管理,遇到一些坑,以此做记录,脑袋往东西快,方便以后忘了的时候再看看。
码云其实和gitHub差不多,只是在码云上做公司项目的时候设置为私有项目是免费的,貌似在gitHub上是要收费的。我这里使用的是sourceTree工具进行的源码的管理。
使用的步骤
第一步:打开码云的官网注册,登录。官网链接
http://git.oschina.net/
登录之后如下图所示:

第二步:创建自己的私有仓库
1.如下图所示,点击新建项目

选择私有的,开始创建项目

点击创建之后,就会出现以下的页面,如图所示的就是自己的仓库的路径,但是,就是在这里遇到的坑,这样操作之后,我们需要的打开sourceTree的客户端,当输入克隆的URL的时候,会提示是无效的git路径,所以就需要下一步,配置配置SSH公钥

第三步:配置SSH公钥
上面已经说了,如果步配置这个公钥的话,就会遇到坑。
配置公钥就在个人信息里面

下图就是公钥的页面

第四步:生成Mac版本的公钥
生成公钥的时候,需要打开终端,输入ssh-keygen -t rsa -C "xxxxx@xxxxx.com",引号里面是你自己的邮箱的地址,然后点击四次回车
具体的操作如下图所示:

然后输入:cat ~/.ssh/id_rsa.pub 来查看你的SSH公钥,显示如下图所示

将公钥复制到刚才提到的码云的SSH公钥的那里


点击确定输入密码即可。
最后在终端上输入ssh -T git@git.oschina.net

出现Welcome to Git@OSC, ***,就表示成功了。
第五步:生成本地仓库
本文开头说了,我用的是sourceTree工具进行的源码的管理,所以打开sourceTree。但是首先要获取的是私有仓库的路径

接下来打开sourceTree,添加新仓库,从URL克隆


然后点击右下角的克隆就可以了。


如上图所示的创建好之后,把自己的项目放到刚才创建的文件夹里就是本地仓库里面就行,就可以把推到远程的私有仓库了。一个远程的仓库可以对应多个本地仓库,一个本地的仓库只能对应一个远程仓库。当多人开发的时候,其他的小伙伴可以根据远程仓库的地址生成本地的仓库,共享项目。
小坑:
1.在没有配置ssh公钥的时候,打开sourceTree克隆,就会提示无效的git路径,所以先要配置好ssh公钥
2.在注册sourceTree的时候,可能会因为网络的问题打不开,这时候就需要翻墙解决了。
网友评论
但是 只有一个目录下 git commit 后可以 git push 其他git push 就提示 下面那个提示
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://git.oschina.net/xxx/xxxxxxx.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.