參考:https://www.cnblogs.com/bluestorm/p/6252900.html
https://my.oschina.net/u/219482/blog/285584
https://blog.csdn.net/zxy987872674/article/details/79273148
1.查看
遠端分支 git branch -r
本地分支 git branch
2.從已有的分支創建新的分支(如從master分支),創建一個dev分支
git checkout -b 1
創建完可以查看一下,分支已經切換到dev
或者:
如果用命令行,運行 git fetch,可以將遠程分支信息獲取到本地,再運行 git checkout -b local-branchname origin/remote_branchname 就可以將遠程分支映射到本地命名爲local-branchname 的一分支
3.提交該分支到遠程倉庫
git push origin 1
4.測試
git pull origin 1
5.設置git push,pull默認的提交獲取分支,這樣就很方便的使用git push 提交信息或git pull獲取信息
git branch --set-upstream-to=origin/dev
6.git commit ,git push,之後就可以直接提交到遠程的1分支中,而不會是master
git命令
在本地新建一個分支: git branch newBranch
切換到你的新分支: git checkout newBranch
將新分支發佈在github上: git push origin newBranch
在本地刪除一個分支: git branch -d newBranch
在github遠程端刪除一個分支: git push origin :newBranch (分支名前的冒號代表刪除)
/git push origin –delete newBranch
注意刪除遠程分支後,如果有對應的本地分支,本地分支並不會同步刪除!