Git提交本地代碼至分支(詳細(xì)每一步)

一、查看分支
A: 查看本地分支
使用 git branch命令,如下:git branch

*標(biāo)識的是你當(dāng)前所在的分支
?
B: 查看遠(yuǎn)程分支
命令如下:git branch -r

C: 查看所有分支
命令如下:git branch -a

二、本地創(chuàng)建新分支
命令如下:git branch [分支名稱]
例如:git branch plateformSuperdog
?
三、切換到新分支
命令如下:git checkout [分支名稱]
例如:git checkout plateformSuperdog
?
四、創(chuàng)建+切換分支
命令如下:git checkout -b [分支名稱]
例如:git checkout -b plateform2
?
其中:git checkout -b [分支名稱]相當(dāng)于兩步
git branch [分支名稱]
git checkout [分支名稱]
?
五、將新分支推送到github
命令如下:git push origin [分支名稱]
?
六:刪除本地分支
命令如下:git branch -d [分支名稱]
?
七、刪除github 遠(yuǎn)方分支
命令如下:git push origin :[branch name]
其中:分支前面:代表刪除
例如:git push origin : plateform2
?
八:git 提交本地代碼至新分支
1.切換到新分支
命令如下:git checkout [分支名稱]
例如:git checkout plateform2
2.添加本地需要提交的代碼
命令如下:git add .
3.提交本地代碼
命令如下:git commit -m "修改說明"
4.push到git倉庫
命令如下:git push origin [分支名稱]
例如:git push origin plateform2