利用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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM