Git切換分支並提交到遠程分支


1. 在本地需要提交的文件同級目錄運行git bash

2. 初始化 git 運行環境

$ git init

3. 新建本地分支develop

$ git checkout -b decelop

4. 鏈接遠程倉庫

$ git remote add origin remote_address   

5. 同步遠程倉庫信息

$ git pull

 

6. 關聯本地倉庫與遠程倉庫

$ git branch --set-upstream-to=origin/develop develop

7. 若遇報錯: branch 'develop' does not exist

則運行如下指令:

$ git pull origin branch --allow-unrelated-histories
$ git branch --set-upstream-to=origin/develop develop

8. 查看當前分支跟蹤的遠程分支

$ git branch -vv

9. 同步遠程分支

$ git pull

 

10. 提交修改到遠程分支

$ git add .
$ git commit -m "modify description"
$ git push

 


免責聲明!

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



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