Git版本控制:Gitlab及Coding.net的使用

来源:互联网 发布:手机淘宝人工客服在哪 编辑:程序博客网 时间:2024/05/19 11:45

http://blog.csdn.net/pipisorry/article/details/50709014

Gitlab介绍

 GitLab是利用 Ruby on Rails 一个开源的版本管理系统,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目。

它拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找。在线DEMO

注册gitlab

出错:There was an error with the recaptcha code below. Please re-enter the code: 

Because recaptcha is provided by google, but it is blocked in China, so you probably need VPN in order to get the code.

recaptcha就是这个验证码,类似12306,需要翻墙才能看到。


之后就可以看到gitlab相关的功能了。


在gitlab上创建一个项目

安装git并配置本地git[Git版本控制教程 - Git本地仓库]

配置远程设置[Git版本控制教程 - Git远程仓库]

这样就可以通过git push -u origin master提交代码了

[GitLab版本管理]

皮皮Blog




Coding的介绍和使用

国内较好的代码托管平台有coding.net等

初始操作

注册coding.net  Git 代码托管 - Coding.net

coding上创建项目

可以创建私人项目和公有项目

私人项目不仅保密还有更多功能,如上传文件到文件夹中的功能。公有项目只能将word文档也加入到git管理中来上传文件。不过私有项目只能创建10个,多了要付费。

安装git

配置本地git并提交

pika:/media/pika/files/mine/python_workspace/RecSys/TianChi$

$ git init

$ git config --global user.name "pipilove"

$ git config --global user.email "***@126.com"

$ git add .

$ git commit -m 'init commit'

[Git版本控制教程 - Git本地仓库]

远程ssh-rsa公钥配置

$ssh-keygen -t rsa -C "***@126.com"

设置SSH-RSA公钥内容:账户》ssh公钥》填上任意Title(如pipi ubuntu) > 在Key文本框里粘贴id_rsa.pub文件(pika:~$    cat .ssh/id_rsa.pub )的内容 > “Add Key”

$git remote add origin git@gitlab.com:***.git    #git地址在项目>代码>SSH 方式访问仓库:copy

Note: git变更项目地址: git remote set-url origin git@***.git;  查看git提交和拉取地址: $ git remote -v;  查看git配置:git config --list

$git push -u origin master     #这样就可以通过git push -u origin master提交代码了

多分支处理

$git branch dev

$git merge dev

$git checkout dev

$git push origin dev

这时最好就处在dev分支上进行代码开发

添加项目好友:成员》项目成员添加+》马上邀请好友》你的专属邀请链接》发给项目其它成员进行注册。成员注册完成后会自动关注项目管理者,项目管理者要在成员添加的粉丝中添加这个好友就可以了。

如成员已注册直接在 成员》项目成员添加+》添加邮箱搜索再添加进来就可以了。

协作者操作

注册coding.net:上面项目管理者发的注册链接。

等待项目所有者添加你到上面创建的项目中

安装git

远程ssh-rsa公钥配置:

$ssh-keygen -t rsa -C "***@126.com"

设置SSH-RSA公钥内容:coding账户》ssh公钥》填上任意Title(如pipi ubuntu) > 在Key文本框里粘贴id_rsa.pub文件(pika:~$    cat .ssh/id_rsa.pub )的内容 > “Add Key”

$git remote add origin git@gitlab.com:***.git    #git地址在项目>代码>SSH 方式访问仓库:copy

创建一个代码存放目录,再拉取运程coding项目中已存在分区:git pull origin dev

[Git版本控制教程 - Git远程仓库]

上传限制

注意:coding上传文件大小没有100m限制,不过每个免费的项目代码加起来不能超过1G。超过1G会报错:

Coding.net Tips : [Repo size exceeded quota : 1024M. See https://coding.net/upgrade for more details.]
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.



Coding.net部署公钥

如果只是想让别人看而不是上传,可以使用部署公钥。部署公钥用以部署项目,只拥有只读权限,且不能跟个人公钥通用。

部署公钥在:项目》设置》部署公钥》新建》填上任意Title(如pipi ubuntu) > 在Key文本框里粘贴id_rsa.pub文件的内容 > “Add Key”

git push会出错:$git push -u origin master

Coding.net Tips : [Deploy key is not allowed to push!]
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

Deploy keys only have read-only access to the repo. If you wish to push, you need to add an SSH key to your user and make sure git is using that key, not the deploy key.

[coding doc]

from: http://blog.csdn.net/pipisorry/article/details/50709014

ref:


1 0