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            //强制推送到远程仓库
  • 相关阅读:
    商贸通帐套隐藏方法
    固定资产打开提示:上年度数据未结转!
    ZOJ 2432 Greatest Common Increasing Subsequence
    POJ 1080 Human Gene Functions
    POJ 1088 滑雪
    POJ 1141 Brackets Sequence
    POJ 1050 To the Max
    HDOJ 1029 Ignatius and the Princess IV
    POJ 2247 Humble Numbers
    HDOJ 1181 变形课
  • 原文地址:https://www.cnblogs.com/expiator/p/6439370.html
Copyright © 2011-2022 走看看