1,查看全部分支:git
git branch
*號在哪代表當前分支在哪。github
2,新建一個分支:spa
git branch featureq(分支名)
轉到該分支下:3d
git checkout featureq
咱們新建分支並轉到那裏須要兩步,實際上咱們用這句一步就搞定了:code
git checkout -b feature2
3,刪除分支,這裏我試了下,在當前分支時候不能刪除,只能在別的分支下刪除他。固然還有別的狀況下也不能刪除,好比那個分支作了變更但沒合併,這時候能夠用D刪除,可是慎用。blog
git branch -d feature2
4,獲取指定分支上的代碼,這裏指的是獲取分支名爲branch2的代碼。rem
git clone -b branch2 https://github.com/ndnmonkey/gittest1.git
「branch2 」表明分支名字,後面跟上這個https就行。it
5,本地修改後,更新代碼到gitclass
先鏈接git:test
git remote add origin https://github.com/ndnmonkey/gittest1.git
而後查看git branch看看你想上傳到哪一個git分支中,選擇並上傳便可。
注意這裏也可在最後一步git push origin + 分支名