美文网首页软件测试职业探索
实操:用Linux克隆git库,创建、打包和上传文件

实操:用Linux克隆git库,创建、打包和上传文件

作者: 895ec9239d2e | 来源:发表于2017-06-17 23:03 被阅读1551次

    一、安装git

    官网链接 https://git.kernel.org/pub/scm/git/git.git/refs/tags

    具体可以参照文章:http://www.jianshu.com/p/0e67b4545d08

    在安装过程中出现了两次错误,均是python升级版本后未把配置文件中的python版本指向以前的旧版本,导致编译安装时出错。

    二、配置git

    1、查看git版本

    [root@localhost ~]# git --version

    git version 2.13.1

    2、配置用户和邮箱

    [root@localhost ~]# git config --global user.name "Winnie-SZ"

    [root@localhost ~]# git config --global user.email "277420864@qq.com"

    配置完查看是否配置成功

    [root@localhost ~]# git config --global user.name

    Winnie-SZ

    [root@localhost ~]# git config --global user.email

    277420864@qq.com

    3、配置默认的文本编辑器 vim

    [root@localhost ~]# git config --global core.editor vim

    4、查看git的所有配置:

    [root@localhost ~]# git config --list

    user.name=Winnie-SZ

    user.email=277420864@qq.com

    core.editor=vim

    core.repositoryformatversion=0

    core.filemode=true

    core.bare=false

    core.logallrefupdates=true

    备注:上述操作中的 global命令,代表“全局设置”,即整个系统中的git管理都遵循此种配置。与之对应的有 local命令,代表“本地设置”,只是部分项目的独立设置。(选自同学的文章)

    三、git操作实例

    1、在本地创建git仓库:hello-world

    1)、在windows系统上通过浏览器登陆https://github.com建库。

    https://github.com/Winnie-SZ/hello-world

    新建库hello-world只添加了一个文件:README.md

    2)、clone代码

    克隆命令:git clone https://github.com/Winnie-SZ/hello-world.git

    clone后,本地自动生成 hello-world 库,里面包含文件README.md

    可用命令 ll 查看

    3)、进入目录 hello-world

    [root@localhost ~]# cd hello-world

    4)、初始化 git

    [root@localhost hello-world]# git init

    2、在hello-world库中添加文件

    1)、在hello-world库中创建文件夹:a-folder、b-folder、c-folder

    [root@localhost hello-world]# mkdir a-folder

    [root@localhost hello-world]# mkdir b-folder

    [root@localhost hello-world]# mkdir c-folder

    2)、创建文件:config.xml

    [root@localhost hello-world]# touch config.xml

    3)、查看创建的内容

    [root@localhost hello-world]# ll

    4)在文件夹中创建子文件,并编辑内容

    [root@localhost hello-world]# cd a-folder

    [root@localhost a-folder]# touch a-file

    [root@localhost a-file]# vi a-file      (合理地编写一些内容)

    5)、查看文件内容

    [root@localhost a-file]# cat a-file

    6)、同理创建 b-file、c-file

    7)、编辑 config.xml 并查看

    [root@localhost hello-world]# vi config.xml

    [root@localhost hello-world]# cat config.xml

    3、打包已有文件,并部署到目录 /APP/www

    1)、打包文件 a-folder、b-folder、c-folder、config.xml、README.md

    [root@localhost hello-world]# tar -cvf istester.tar.gz a-folder b-folder c-folder config.xml README.md

    2)、新建目录 /APP/www

    [root@localhost hello-world]# mkdir -p /APP/www

    3)、移动 istester.tar.gz 到 /APP/www

    [root@localhost hello-world]# mv istester.tar.gz /APP/www

    4)、解压 istester.tar.gz

    [root@localhost hello-world]# cd /APP/www

    [root@localhost www]# tar -xvf istester.tar.gz

    4、提交文件到git仓库:hello-world

    1)、添加所有的文件

    [root@localhost hello-world]# git add -A

    2)、查看git状态

    [root@localhost hello-world]# git status

    3)、提交修改的内容

    [root@localhost hello-world]# git commit -m "first commit"

    4)、上传本地所有分支代码到远程对应的分支

    [root@localhost hello-world]# git push -u origin master

    5)、从浏览器打开 hello-world 库查看结果

    查看上传结果

    不够熟悉,比较容易出错,还需要多多研究和练习,以上仅做学习记录,如有错漏,请不吝指出,谢谢。

    2017/6/17

    相关文章

      网友评论

        本文标题:实操:用Linux克隆git库,创建、打包和上传文件

        本文链接:https://www.haomeiwen.com/subject/mmtbqxtx.html