zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    魔法方法中的__str__和__repr__区别
    新建分类目录后,点击显示错误页面?
    3.用while和for循环分别计算100以内奇数和偶数的和,并输出。
    2.for循环实现打印1到10
    1.while循环实现打印1到10
    021_for语句
    014_运算符_字符串连接
    020_while语句
    019_增强switch语句
    018_switch语句
  • 原文地址:https://www.cnblogs.com/change06/p/9795558.html
Copyright © 2011-2022 走看看