原文地址https://blog.csdn.net/liushunCSDNblog/article/details/78369353
一、码云公钥管理
开发者向码云版库写入到的协议是SSH协议,因为SSH协议使用公钥认证,可以实现无口令访问,而若使用HTTPS协议每次身份认证时都需要提供口令。
1、Linux上对Git进行全局配置
该配置只需做一次且对该Linux主机上所有Git管理项目生效:
[liushun@centos6 ~]$ git config --global user.name"liushun"
[liushun@centos6 ~]$ git config --global user.email"1710275579@qq.com"
2、Linux上生成SSH key:
[liushun@centos6 ~]$ ssh-keygen -t rsa -C "1710275579@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/liushun/.ssh/id_rsa):[回车]
Created directory '/home/liushun/.ssh'.
Enter passphrase (empty for no passphrase):[回车]
Enter same passphrase again:[回车]
Your identification has been saved in /home/liushun/.ssh/id_rsa. #私钥
Your public key has been saved in /home/liushun/.ssh/id_rsa.pub. #公钥
The key fingerprint is:
aa:a6:c6:fd:26:1e:95:c9:77:68:d4:ac:2c:2d:bc:e31710275579@qq.com
The key's randomart image is:
+--[ RSA 2048]----+
| |
| o |
| . o |
| o * o |
| O S . |
| . B . |
| . .. + |
| o ++.. |
| ..+o+E |
+-----------------+
3、上传public key:
查看public key 并拷贝,将他添加到码云个人账号的SSH公钥里:
[liushun@centos6 ~]$ cat ~/.ssh/id_rsa.pub
ssh-rsa ..............== 1710275579@qq.com 中间省略
4、公钥添加测试:
[liushun@centos6 ~]$ ssh -T git@git.oschina.net
Welcome to Gitee.com, liushun!
5、git下载测试:
[liushun@centos6 ~]$ git clone git@gitee.com:YouMengXiangDeMiao/FL2440.git
Initialized empty Git repository in /home/liushun/FL2440/.git/
The authenticity of host 'gitee.com (120.55.226.24)' can't be established.
RSA key fingerprint is e3:ee:82:78:fb:c0:ca:24:65:69:ba:bc:47:24:6f:d4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitee.com' (RSA) to the list of known hosts.
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.95 KiB, done.
[liushun@centos6 ~]$ ls ls看看文件已经下下来了
FL2440
[liushun@centos6 ~]$ ls FL2440/
LICENSE README.md
6、SVN下载测试:
[liushun@centos6 ~]$ svn co svn://gitee.com/YouMengXiangDeMiao/FL2440 --username=1710275579@qq.com
Authentication realm: <svn://gitee.com:3690>gitee.com
Password for '1710275579@qq.com': #输入码云登录密码
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
<svn://gitee.com:3690>gitee.com
can only be stored to disk unencrypted! You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible. See the documentation for details.
You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/home/liushun/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
-----------------------------------------------------------------------
ATTENTION! Your password for authentication realm:
<svn://gitee.com:3690>gitee.com
can only be stored to disk unencrypted! You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible. See the documentation for details.
You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/home/liushun/.subversion/servers'.
-----------------------------------------------------------------------
Store password unencrypted (yes/no)? yes
A FL2440/LICENSE
A FL2440/README.md
Checked out revision 1.
二、Linux上的git基本操作
1、本地clone码云上的项目:
[liushun@centos6 ~]$ mkdir gitee
[liushun@centos6 ~]$ cd gitee/
[liushun@centos6 gitee]$ ls
[liushun@centos6 gitee]$ mkdir iot-yun
[liushun@centos6 gitee]$ cd iot-yun/
[liushun@centos6 iot-yun]$ git clone git@gitee.com:YouMengXiangDeMiao/FL2440.git
Initialized empty Git repository in /home/liushun/gitee/iot-yun/FL2440/.git/
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.95 KiB, done.
[liushun@centos6 iot-yun]$ ls
FL2440
[liushun@centos6 iot-yun]$ ls FL2440/
LICENSE README.md #文件已经下下来了
2、创建FL2440项目源码结构:
[liushun@centos6 ~]$ cd FL2440
[liushun@centos6 FL2440]$ ls
LICENSE README.md
[liushun@centos6 FL2440]$ mkdir -p {crosstool,linux/{kernel,rootfs},driver,3rdparty,program,images}
[liushun@centos6 FL2440]$ ls
3rdparty crosstool driver images LICENSE linux program README.md
[liushun@centos6 FL2440]$
3、本地创建文件并提交服务器;
注意:git不能管理文件夹,只能管理文件
[liushun@centos6 FL2440]$ cd crosstool/
[liushun@centos6 crosstool]$ vim build.sh
#!/bin/bash
#This shell script used to downlaod crosstool-ng install and compile it for arm920tCRO
SSTOOL=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-L
ingyun-v1.0.0.bin
fi
chmod a+x ${CROSSTOOL}
./${CROSSTOOL}
[liushun@centos6 crosstool]$ ls
build.sh
[liushun@centos6 crosstool]$ chmod a+x build.sh
[liushun@centos6 crosstool]$ cd ..
SVN提交新创建的文件到服务器
[liushun@centos6 FL2440]$ ls
3rdparty crosstool driver images LICENSE linux program README.md
[liushun@centos6 FL2440]$ svn add crosstool/
A crosstool
A crosstool/build.sh
[liushun@centos6 FL2440]$ svn ci -m"Add crosstool biuld shell script"
Adding crosstool
Adding crosstool/build.sh
Transmitting file data .
Committed revision 2. #文件上传成功
4、文件修改提交
[liushun@centos6 FL2440]$ ls
3rdparty crosstool driver images LICENSE linux program README.md
[liushun@centos6 FL2440]$ vim crosstool/build.sh #用vim对文件进行修改,修改完退出vim
[liushun@centos6 FL2440]$ svn diff
Index: crosstool/build.sh
===================================================================
--- crosstool/build.sh (revision 2)
+++ crosstool/build.sh (working copy)
@@ -6,3 +6,4 @@
fi
chmod a+x ${CROSSTOOL}
./${CROSSTOOL}
+hello world! #我在原来的文件上加了hello world!
[liushun@centos6 FL2440]$ svn ci -m"update crosstool/biuld.sh,add author in the script" #让服务器更新文件
Sending crosstool/build.sh
Transmitting file data .
Committed revision 3.
[liushun@centos6 FL2440]$
然后再上网站,可以看到数据更新的信息!
5、文件删除后同步:
[liushun@centos6 FL2440]$ rm -rf crosstool/
[liushun@centos6 FL2440]$ ls
3rdparty driver images LICENSE linux program README.md #可以看到crosstool整个文件夹都被删除
[liushun@centos6 FL2440]$ svn up
A crosstool
A crosstool/build.sh
Updated to revision 3.
[liushun@centos6 FL2440]$ ls crosstool/
build.sh # 文件找回
[liushun@centos6 FL2440]$
---------------------
作者:有梦想的猫
来源:CSDN
原文:https://blog.csdn.net/liushunCSDNblog/article/details/78369353
版权声明:本文为博主原创文章,转载请附上博文链接!