0.下载Git Bash,在Windows系统可以用Git Bash通过简单的命令将代码提交到GitHub
1.打开项目所在的文件夹,右键,"Git Bash Here"
使用git提交代码到GitHub
2.初次使用需要设置名字和邮箱:
你的名字
你的邮箱
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提交代码到GitHub
具体的git项目地址在下图处获得:
使用git提交代码到GitHub
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            //强制推送到远程仓库

相关文章:

  • 2022-12-23
  • 2021-06-16
  • 2021-11-25
  • 2021-11-30
  • 2021-09-09
  • 2021-12-15
猜你喜欢
  • 2021-11-30
  • 2021-04-18
  • 2022-12-23
  • 2022-02-01
  • 2022-01-29
  • 2021-09-21
  • 2021-08-04
相关资源
相似解决方案