码云GIT和SVN使用说明

一.前言

    1.版本和版本控制

    版本控制(Revision control)是一种软件工程技巧,籍以在开发的过程中,确保由不同人所编辑的

同一档案都得到更新。它会记录程序各个模组的改动,并为每次改动编上序号,这样可以查看所有的

修改历史记录。软件系统的版本号由3部分构成,即主版本号+次版本号+修改号,如Linux内核源码

linux-4.2.6(主版本号为4,次版本号为2,修订版本号为6):

    2.版本控制系统

    常见版本控制系统有Git、SVN、CVS(以前)、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一般是整个项目;

 

    4.国内外源代码交给第三方托管使用情况

    (1)github、sourceforge(国外普遍使用)需要翻墙

    (2)码云(拥有2种版本控制系统GIT、SVN)

二.码云上创建项目

    1.码云上创建项目

    首先在浏览器上使用自己的帐号登录码云官方站点,然后如下图两种方法创建

项目:并且默认创建2个文件(选GPL)

右上角:

左下角:

创建过程:

注:在码云上创建的项目默认使用GIT来控制,如果需要修改成SVN来控制则右上角处里头修改成SVN控制。

    2.码云上删除项目

    3.克隆/下载

    由于我选择的是GIT控制管理方式故没有SVN选项下载

    两者下载链接不能混淆

三、码云公钥管理

    开发者向码云版本库写入最常用到的协议是 SSH 协议,因为 SSH 协议使用公钥认证(非对称加密算法),可以实

现无口令访问,而若使用 HTTPS 协议每次身份认证时都需要提供口令。

    

    1.Linux上对git进行全局配置

    该配置只需做一次且对该Linux主机上所有git管理项目生效:    

[guozhihao@centos6_master ~]$ git config --global user.name "guozhihao"
[guozhihao@centos6_master ~]$ git config --global user.email "guozhihao@gmail.com"

    

    2.Linux上生成SSH key:  

[guozhihao@centos6_master ~]$ ssh-keygen -t rsa -C "guozhihao@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/guozhihao/.ssh/id_rsa):   按回车
/home/guozhihao/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):  按回车
Enter same passphrase again:  按回车
Your identification has been saved in /home/guozhihao/.ssh/id_rsa.     私钥
Your public key has been saved in /home/guozhihao/.ssh/id_rsa.pub.   公钥
The key fingerprint is:
+--[ RSA 2048]----+
.....

 

    3.上传Public Key:

    查看public key并拷贝,将他添加到码云个人帐号的SSH公钥里:

    [guozhihao@centos6_master ~]$ cat ~/.ssh/id_rsa.pub

    ssh-rsa ******** == guozhihao@gmail.com

    

    4.公钥添加测试:  

[guozhihao@centos6_master ~]$ ssh -T git@git.oschina.net
The authenticity of host 'git.oschina.net (120.55.226.24)' can't be established.
.....
Are you sure you want to continue connecting (yes/no)? yes
.....
Welcome to Gitee.com, guozhihao!

注:如果说家里有一台,公司有一台,那么要想公司和家里都能连的上就需要拷贝公钥和私钥到 ~/.ssh里头类似身份证。

    

    5.git下载测试:

    

[guozhihao@centos6_master ~]$ git clone git@gitee.com:PipiAvenger/fl2440.git(这里的下载地址是需要上网站获取)

    找到需要下载的项目后:

    复制获得的网址在Linux操作环境下输入命令git clone +复制代码

    Initialized empty Git repository in /home/guozhihao/fl2440/.git/

    ....

注:拷贝是拷贝到当前文件夹下

    

    6.svn下载测试1

    svn使用时用户名为码云登录时使用的邮箱地址,密码为该邮箱登录的密码

    在使用前需要用yum install安装svn才可使用这个命令   

[guozhihao@localhost svn-fl12440]$ svn co svn://gitee.com/PipiAvenger/fl2440 --username=PipiAvenger
Authentication realm: <svn://gitee.com:3690>gitee.com
.....

四、Linux上git基本操作

    1.本地clone码云上的项目:    

[guozhihao@centos6_master ~]$ cd gitee/
[guozhihao@centos6_master gitee]$ git clone git@gitee.com:PipiAvenger/fl2440.git
......
[guozhihao@centos6_master gitee]$ cd fl2440/
[guozhihao@centos6_master fl2440]$ ls
LICENSE  README.md

    2.创建FL2440项目源码结构:

   

[guozhihao@centos6_master gitee]$ mkdir -p {crosstool,bootloader,linux/{kernel,rootfs},driver,3rdparty,program,images}

    

    3.本地创建文件并提交服务器

注意: git不能管理空文件夹,只能管理文件:  

[guozhihao@localhost crosstool]$ ls
[guozhihao@localhost fl2440]$ vim build.sh
#!/bin/bash
# This shell script used to download crosstool-ng install binary and compile it for arm920t
CROSSTOOL=crosstool-ng-centos-LingYun-v1.0.0.bin
if [ ! -f ${CROSSTOOL} ] ; then
wget ftp://master.iot-yun.com/linux_tools/${CROSSTOOL}
sed -i -e "s|^sup_arch=.*|sup_arch=(\"\", \"arm920t\")|g" crosstool-ng-centos-LingYun-v1.0.0.bin
 fi
chmod a+x ${CROSSTOOL}
./${CROSSTOOL}
[guozhihao@localhost crosstool]$ chmod a+x build.sh
[guozhihao@localhost crosstool]$ cd ..

git提交新创建的文件到服务器

[guozhihao@localhost fl2440]$ git add crosstool/    //将crosstool保存本地
[guozhihao@localhost fl2440]$ git commit -m"Add crosstool build shell script"    //添加说明
[master 4cd53b5] Add crosstool build shell script
1 files changed, 9 insertions(+), 0 deletions(-)
create mode 100755 crosstool/build.sh
[guozhihao@localhost fl2440]$ git push    //发送
Counting objects: 5, done.
....

 

    4.文件修改提交  

[guozhihao@localhost crosstool]$ vim build.sh
[guozhihao@localhost crosstool]$ git diff build.sh
diff --git a/crosstool/build.sh b/crosstool/build.sh
index 9858a06..27f8b61 100755
--- a/crosstool/build.sh
+++ b/crosstool/build.sh
@@ -1,4 +1,5 @@
#!/bin/bash
+#Author:guozhihao<guozhihao@gmail.com>
.....
(END)

git提交修改后的文件到服务器    

[guozhihao@localhost fl2440]$ git add crosstool/build.sh
[guozhihao@localhost fl2440]$ git commit -m"update crosstool/build.sh,add author in the script"
[master 0b07486] update crosstool/build.sh,add author in the script
1 files changed, 1 insertions(+), 0 deletions(-)
[guozhihao@localhost fl2440]$ git push
Counting objects: 7, done.
....

 

    5.文件删除后同步:  

[guozhihao@localhost fl2440]$ rm -rf crosstool/
[guozhihao@localhost fl2440]$ git checkout
D       crosstool/build.sh
[guozhihao@localhost fl2440]$ git checkout ..
fatal: '..' is outside repository
[guozhihao@localhost fl2440]$ git checkout .
[guozhihao@localhost fl2440]$ ls
3rdparty    crosstool  images   linux    README.md
bootloader  driver     LICENSE  program  t crosstool]$ ls

    

五、Linux上svn基本操作

    1.本地clone码云上的项目:   

[guozhihao@localhost svn-fl12440]$ svn co svn://gitee.com/PipiAvenger/fl2440
A    fl2440/LICENSE
A    fl2440/README.md
A    fl2440/crosstool
A    fl2440/crosstool/build.sh
Checked out revision 3.
[guozhihao@localhost svn-fl12440]$ ls
fl2440
[guozhihao@localhost svn-fl12440]$ cd fl2440/
[guozhihao@localhost fl2440]$ ls
crosstool  LICENSE  README.md

    

    2.创建FL2440项目源码结构:  

[guozhihao@centos6_master fl2440]$ mkdir -p {crosstool,bootloader,linux/{kernel,rootfs},driver,3rdparty,program,images}

    3.本地创建文件并提交服务器

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

[guozhihao@centos6_master fl2440]$ cd crosstool/
[guowenxue@centos6_master crosstool]$ vim build.sh
#!/bin/bash
# This shell script used to download crosstool-ng install binary and compile it for arm920t
CROSSTOOL=crosstool-ng-centos-LingYun-v1.0.0.bin
if [ ! -f ${CROSSTOOL} ] ; then
wget ftp://master.iot-yun.com/linux_tools/${CROSSTOOL}
sed -i -e "s|^sup_arch=.*|sup_arch=(\"\", \"arm920t\")|g" crosstool-ng-centos-LingYun-v1.0.0.bin
fi
chmod a+x ${CROSSTOOL}
./${CROSSTOOL}
[guozhihao@centos6_master crosstool]$ chmod a+x build.sh
[guozhihao@centos6_master fl2440]$ cd ..

    svn提交新创建的文件到服务器   

[guozhihao@centos6_master fl2440]$ svn add crosstool/
A         crosstool
A         crosstool/build.sh
[guozhihao@centos6_master fl2440]$ svn ci -m"Add crosstool build shell script"
Adding         crosstool
Adding         crosstool/build.sh
....

 

    4.文件修改提交  

[guozhihao@centos6_master fl2440]$ vim crosstool/build.sh
[guozhihao@centos6_master fl2440]$ svn diff
Index: crosstool/build.sh
===================================================================
--- crosstool/build.sh  (revision 2)
+++ crosstool/build.sh  (working copy)
@@ -1,4 +1,5 @@
#!/bin/bash
+# Author: guozhihao<guozhihao@gmail.com>
# This shell script used to download crosstool-ng install binary and compile it for arm920t
CROSSTOOL=crosstool-ng-centos-LingYun-v1.0.0.bin
if [ ! -f ${CROSSTOOL} ] ; then
[guozhihao@centos6_master fl2440]$ svn ci -m"update crosstool/build.sh, add author in the
script"         
....

    5.文件删除后同步:    

[guozhihao@centos6_master fl2440]$ rm -rf crosstool/
[guozhihao@centos6_master fl2440]$ svn up
A    crosstool
A    crosstool/build.sh
Updated to revision 3.
[guozhihao@centos6_master fl2440]$ ls crosstool/
build.sh

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值