学会使用码云管理文件

使用码云带来的好处:

  • 代码共享
  • 文件恢复
  • 源码维护
  • 版本控制

常见版本控制系统有Git、SVN、CVS、Git、Mercurial,目前主流使用的最多的就是git和svn,下面是这两种版本控制系统的比较:

  1. GIT是分布式的,SVN是集中式管理;
  2. GIT把内容按元数据方式增量存储,而SVN是按文件; <.svn .git >
  3. GIT分支和SVN的分支不同;
  4. GIT的内容完整性要优于SVN:
  5. git内容存储使用的是SHA-1哈希算法;
  6. SVN有一个全局的整数编号,而git则是一个SHA-1值作编号:
  7. SVN控制粒度可以到某个目录(当然很少这样做);而git一般是整个项目;

一、创建项目

 1. 点击“+”->"新建项目"
 2. 填写归属->填写名称->路径自动匹配->介绍(非必填)->选择程序语言(如C)->添加.gitignore->加密方式(如GPL v2)->相应填写是否公开->保存
 3. (可选)开启svn访问:点进项目->管理->基本设置->启用svn访问

二、公钥管理

开发者向码云版本库写入最常用到的协议是 SSH 协议,因为 SSH 协议使用公钥认证,可以实
现无口令访问,而若使用 HTTPS 协议每次身份认证时都需要提供口令。

1.若服务器没有安装git服务,首先安装

[root@VM_83_82_redhat ~]# yum install git git-gui

2.对git进行全局配置

[yanhuan@VM_83_82_redhat ~]$ git config --global user.name"yanhuan"
[yanhuan@VM_83_82_redhat ~]$ git config --global user.email"*****@foxmail.com"
//用户名和邮箱应为自己实际姓名而非登录名

3.生成SSH秘钥

[yanhuan@VM_83_82_redhat ~]$ ssh-keygen -t rsa -C "*****@foxmail.com"  //对应上方邮箱
Generating public/private rsa key pair.
Enter file in which to save the key (/home/yanhuan/.ssh/id_rsa):       //选择秘钥保存路径
Created directory '/home/yanhuan/.ssh'. 
Passphrases do not match.  Try again.
Enter passphrase (empty for no passphrase):     //linux账号的密码
Enter same passphrase again: 
Your identification has been saved in /home/yanhuan/.ssh/id_rsa.
Your public key has been saved in /home/yanhuan/.ssh/id_rsa.pub.
The key fingerprint is:
3b:2b:69:61:f1:40:77:c0:3a:ff:e8:07:3f:58:1c:cd *****@foxmail.com
The key's randomart image is:
+--[ RSA 2048]----+
|       ...       |
|      . o .      |
|     . o . o     |
|      =   . E    |
|       *S. .     |
|      o +.o      |
|     . ooB       |
|      + oo=      |
|     . oo. .     |
+-----------------+

4.上传秘钥到码云

[yanhuan@VM_83_82_redhat ~]$ cat ~/.ssh/id_rsa.pub               //查看秘钥文件
ssh-rsa AAAA************705R2UZ ******@foxmail.com

这里写图片描述
设置->SSH公钥->添加

5.测试是否连上SVN

[yanhuan@VM_83_82_redhat ~]$ ssh -T git@git.oschina.net
The authenticity of host 'git.oschina.net (120.55.226.24)' can't be established.
ECDSA key fingerprint is 27:e5:d3:f7:2a:9e:eb:6c:93:cd:1f:c1:47:a3:54:b1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.oschina.net,120.55.226.24' (ECDSA) to the list of known hosts.
Enter passphrase for key '/home/yanhuan/.ssh/id_rsa':                   //linux密码
Welcome to Gitee.com, yanhuan!                                          //成功
[yanhuan@VM_83_82_redhat ~]$ 

三、下载

1.git下载

这里写图片描述

[yanhuan@VM_83_82_redhat ~]$ git clone git@gitee.com:************.git
Cloning into 'FL2440KaiFaBan'...
The authenticity of host 'gitee.com (120.55.226.24)' can't be established.
ECDSA key fingerprint is 27:e5:d3:f7:2a:9e:eb:6c:93:cd:1f:c1:47:a3:54:b1.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitee.com' (ECDSA) to the list of known hosts.
Enter passphrase for key '/home/yanhuan/.ssh/id_rsa': 
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (4/4), 6.93 KiB | 0 bytes/s, done.              //git下载成功

2.svn下载

这里写图片描述

注意: 在码云上使用git管理的项目,svn不能管理空文件夹,只能管理文件:

[root@VM_83_82_redhat ~]# yum install subversion                   //首先要有svn

[yanhuan@VM_83_82_redhat ~]$ svn co svn://gitee.com/**********     //svn下载地址
Authentication realm: <svn://gitee.com:3690> gitee.com
Password for 'yanhuan':                                            //linux密码
Authentication realm: <svn://gitee.com:3690> gitee.com
Username: *******@qq.com                                           //码云注册邮箱
Password for '********@qq.com':                                    //码云密码
Authentication realm: <svn://gitee.com:3690> gitee.com
Username: ******@qq.com
Password for '*******@qq.com': 

Store password unencrypted (yes/no)? yes
   C FL2440KaiFaBan/LICENSE
   C FL2440KaiFaBan/README.md
Checked out revision 1.                                //revision 1下载成成功
[yanhuan@VM_83_82_redhat ~]$ ^C
[yanhuan@VM_83_82_redhat ~]$ ls
FL2440KaiFaBan
[yanhuan@VM_83_82_redhat ~]$ ls
FL2440KaiFaBan
[yanhuan@VM_83_82_redhat ~]$ ls FL2440KaiFaBan/
LICENSE  README.md

四、git上传

[yanhuan@VM_83_82_redhat FL2440KaiFaBan]$ git config --global user.name "yanhuan"  
[yanhuan@VM_83_82_redhat FL2440KaiFaBan]$ git config --global user.email "*******@foxmail.com"
[yanhuan@VM_83_82_redhat FL2440KaiFaBan]$ ls crosstool/
build.sh
[yanhuan@VM_83_82_redhat FL2440KaiFaBan]$ git add crosstool/         //git上传crosstoll
[yanhuan@VM_83_82_redhat FL2440KaiFaBan]$ git commit -m"Add crosstool build shell script"   //注释
[yanhuan@VM_83_82_redhat FL2440KaiFaBan]$ git push                  //push上码云

Enter passphrase for key '/home/yanhuan/.ssh/id_rsa':               //linux密码
Counting objects: 5, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 611 bytes | 0 bytes/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To git@gitee.com:yanyanhuan/FL2440KaiFaBan.git
   e172c5b..d442979  master -> master
[yanhuan@VM_83_82_redhat FL2440KaiFaBan]$ git checkout .            //git同步下载

五、svn上传

[yanhuan@VM_83_82_redhat FL2440KaiFaBan]$ svn add crosstool/         //svn上传crosstool
A crosstool
A crosstool/build.sh
[yanhuan@VM_83_82_redhat FL2440KaiFaBan]$ svn ci -m"Add crosstool build shell script"    //注释
[yanhuan@VM_83_82_redhat FL2440KaiFaBan]$ svn diff                   //比较
[yanhuan@VM_83_82_redhat FL2440KaiFaBan]$ svn up                     //svn同步
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值