• ubuntu18上传代码到github


    其实在github上建仓库时候就提示你步骤了:

    1.注册个github账号并登录 创建一个仓库

    https://github.com/

    2.创建SSH Key

    ssh-keygen -t rsa -C "your email“
    

    3.在github上找到SSH and GPG keys   右上头像旁边向下的小小小箭头   --->  点击settings  ----->左侧找到 SSH and GPG keys

    4.在SSH  keys  输入刚才生成的  /.ssh下两个文件中的一个    id_rsa.pub 里的内容。

    5.准备上传  打开终端  输入 git  查看是否已安装git

    如果没有安装:

    sudo apt-get install git
    

    1)接下来 进入我们需要上传项目所在的文件夹

    git init
    

    2)选择要上传的文件 file是你要上传的文件(./是包含了文件夹下所有文件)

     git add file    
    eg: ===
      git add ./

    3)检查当前git状态

    git status
    

    4)commit推送

    git commit -m  “备注信息

      如果提示下面信息

    *** 请告诉我你是谁。
    
    运行
    
      git config --global user.email "you@example.com"
      git config --global user.name "Your Name"
    
    来设置您账号的缺省身份标识。
    如果仅在本仓库设置身份标识,则省略 --global 参数。
    
    fatal: 无法自动探测邮件地址(得到 'root@songke-ubuntu.(none)')

      解决方法:

    该文件下有个生成隐藏的  .git/   

     cd  .git/  =======  vim config
    

     在文件末尾加入内容:

    [user]
     email = your email
     name = your name

     偷懒ing.....

    [user]  
            email = 1967326900@qq.com
            name = songke

     之后再运行commit命令。

    git commit -m  “备注信息”

    6.上传到github   

    1)在github上新建Demo1  复制Clone or download 里的内容

    git remote add origin https://github.com/songke12138/Demo1.git
    

      

    如果提示出错  fatal: 远程 origin 已经存在。

    git remote rm origin
    git remote add origin https://github.com/songke12138/Demo1.git

    2)添加文件到远程库

    git remote set-url origin https://github.com/songke12138/Demo1.git

    3)push

    git push -u origin +master

     =====================================================================

    git常用命令:
    git clone <address>:复制代码库到本地
    git add <file> :添加文件到代码库中
    git rm <file> :删除代码库的文件
    git commit -m <message>:提交更改,在修改了文件以后,使用这个命令提交修改。
    git pull:从远程同步代码库到本地。
    git push:推送代码到远程代码库。
    git branch:查看当前分支。带*是当前分支。
    git branch <branch-name>:新建一个分支。
    git branch -d <branch-name>:删除一个分支。
    git checkout <branch-name>:切换到指定分支。
    git log:查看提交记录(即历史的 commit 记录)。
    git status:当前修改的状态,是否修改了还没提交,或者那些文件未使用。
    git reset <log>:恢复到历史版本。
    

      

  • 相关阅读:
    java,jenkins
    docker compose,link,Odoo
    nginx,docker反向代理
    centos7上安装docker-ce社区版
    Install Rancher server
    docker公司测试环境搭建总结
    ansible+docker
    桥接物理网卡,pipwork指定ip,外网连接,研究salt+docker
    20170605
    20170602
  • 原文地址:https://www.cnblogs.com/songxiaoke/p/11714644.html
Copyright © 2020-2023  润新知