• git基础使用方法


    1.创建密钥
    [root@localhost ~]# ssh-keygen -t rsa -C "youname@email.com"
    [root@localhost ~]# cat .ssh/id_rsa.pub
    把公钥复制到github上

    2. 配置上传时使用的用户名,邮箱
    [root@localhost ~]# git config --global user.name "youname"
    [root@localhost ~]# git config --global user.email "youname@email.com"

    3.下载github上的分支到本地仓库
    [root@localhost ~]# git clone https://github.comyouname/mytest.git


    4.修改mytest仓库文件后上传github
    [root@localhost ~]# vim test.py //编辑文件

    [root@localhost ~]# git add test.py //追踪文件,如果有多个文件或文件夹 可以时可用 "git add ." 追踪文件
    [root@localhost ~]# git commit -m "test python" //把追踪到的文件添加到本地仓库并设置备注
    [root@localhost ~]# git push //上传到github

    5.创建分支并上传到github
    [root@localhost ~]# git branch test2 //创建分支名为test2
    [root@localhost ~]# git checkout test2 //切换到分支
    [root@localhost ~]# vim test2.py
    [root@localhost ~]# git add test2.py
    [root@localhost ~]# git commit -m "test2_py"
    [root@localhost ~]# git push origin test2 //上传文件到分支

    6.删除本地分支和远程分支
    [root@localhost ~]# git branch //查看本地分支
    [root@localhost ~]# git branch -d test2 //删除本地分支
    [root@localhost ~]# git push origin :test2 //删除远程分支,注意分支前面的冒号

    7.创建本地库并同步到远程库
    #创建一个名为demo的本地库,在github上也必须创建一个空库
    [root@localhost ~]# git init demo
    # 进入目录 并追踪目录下的所有文件,更新到本地库
    [root@localhost ~]# cd demo
    [root@localhost ~]# git add .
    [root@localhost ~]# git commit -m "test demo"
    # 链接远程库并进行同步
    # 格式 git remote add <库名> <库url>
    [root@localhost ~]# git remote add demo https://github.com/youname/demo.git
    # 格式 git push <库名> <分支名>
    [root@localhost ~]# git push -u demo master

  • 相关阅读:
    vue-org-tree 组织结构树插件
    vue-pdf 插件预览
    element upload 上传报错 Uncaught TypeError: Cannot set property 'status' of undefined
    element 表格回显默认选中的一行在第一行显示
    swiper轮播图(中间大,两侧小)
    elementui 树控件默认隐藏第三级菜单
    Echarts配置项详解
    elementui禁用树形结构全部复选框
    layui下拉多选formSelects使用方法
    R语言 expression函数
  • 原文地址:https://www.cnblogs.com/change06/p/9795558.html
Copyright © 2020-2023  润新知