zoukankan      html  css  js  c++  java
  • 使用git提交代码到GitHub

    0.下载Git Bash,在Windows系统可以用Git Bash通过简单的命令将代码提交到GitHub
    1.打开项目所在的文件夹,右键,"Git Bash Here"

    2.初次使用需要设置名字和邮箱:
    git config --global user.name 你的名字
    git config --global user.email 你的邮箱
    3.接下来,按如下所示操作:
    touch README.md 添加说明书
    git init 初始化一个本地仓库 git add README.md 添加说明书到暂存区
    git add .  后面的点表示添加整个目录,也可以像git add README.md一样。添加单个文件 git commit -m "first commit" 从暂存区提交到本地仓库
    4.然后提交到自己的github远程仓库,远程仓库名为origin git remote add origin https://github.com/firefoxer1992/CrmMain.git
    想获得上面这个git项目地址,需要先在github里面new(新建)一个repository(仓库)来获得

    具体的git项目地址在下图处获得:

    5.最后输入github账号密码提交代码
    git push -u origin master //将本地仓库的master分支的代码提交到远程仓库的origin分支
    如果报错:Updates were rejected because the remote contains work that you do
    改为如下即可
    git push -f origin master //-f表示force,强制推送
    6.打开github,即可看到提交成功的代码

    二、本地代码更新到远程仓库:
    git add .                               //添加整个目录到暂存区
    git commit -m "second commit"          //提交到本地仓库
    git pull origin master                 //抓取远程仓库代码到本地,并合并本地代码
    git push -f  origin master            //强制推送到远程仓库
  • 相关阅读:
    LVDS DP等显示器接口简介
    Eclipse智能感知及快捷键
    Error deploying web application directory D:apache-tomcat-8.0.26webappsservlet
    把tomcat默认的8080段口改成80端口
    警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server did not find a matching property.
    软件危机
    SQL Server——热备份
    mysql热备份
    Oracle——热备份
    Nodejs基础
  • 原文地址:https://www.cnblogs.com/expiator/p/6439370.html
Copyright © 2011-2022 走看看