利用GIt命令上传项目到GitHub指定仓库

1.建立GIt可管理的仓库

cd到本地项目根目录下,执行 git init 命令:

  git init

2.将项目的所有文件添加到仓库中(注意add后面有一个“ . ”)

  git add .

3.将上一步add的文件commit到仓库

  git  commit -m "提交的说明注释"

4.到GitHub官网新建一个仓库(Create repository),复制仓库地址

5.将本地仓库关联到GitHub新建的仓库上

  git remote add origin https://github.com/Love-LG/Javaweb-firstcup-war

6.使用pull命令

  git pull origin master

7.将本地仓库的文件上传到GitHub远程仓库

  git push -u origin master

如果github上有新的文件,要先下载下来,再push:

  git pull --rebase origion master

8、切换用户: git clone -b branch_name http://xxx  (-b指分支)

      cd branch_name

 再执行push操作

 9、git新建分支并提交本地代码到远程分支

  step1,在本地新建分支

      git branch newbranch

  step2:把本地分支push到远程

    git push origin newbranch

  step3:切换到该分支

    git checkout newbranch

  step4:查看本地修改

    git status

  step5:添加本地修改

    git add .

  step6:commit修改

    git commit -m 'XXXX'

   step7:push代码

    git push

 

转载:https://www.cnblogs.com/yuanchao-blog/p/10547945.html

原文地址:https://www.cnblogs.com/rrl92/p/11236924.html