現(xiàn)在我在master分支上,工作目標(biāo)是干凈的,也沒(méi)有需要commit的:
$ git branch
* master
release
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
新建遠(yuǎn)程分支
新建一個(gè)本地分支:
$ git checkout -b dbg_lichen_star
查看一下現(xiàn)在的分支狀態(tài):
$ git branch
* dbg_lichen_star
master
release
星號(hào)(*)表示當(dāng)前所在分支。現(xiàn)在的狀態(tài)是成功創(chuàng)建的新的分支并且已經(jīng)切換到新分支上。
把新建的本地分支push到遠(yuǎn)程服務(wù)器母债,遠(yuǎn)程分支與本地分支同名(當(dāng)然可以隨意起名):
$ git push origin dbg_lichen_star:dbg_lichen_star
使用git branch -a
查看所有分支,會(huì)看到remotes/origin/dbg_lichen_star
這個(gè)遠(yuǎn)程分支尝抖,說(shuō)明新建遠(yuǎn)程分支成功。
刪除遠(yuǎn)程分支
我比較喜歡的簡(jiǎn)單方式迅皇,推送一個(gè)空分支到遠(yuǎn)程分支昧辽,其實(shí)就相當(dāng)于刪除遠(yuǎn)程分支:
$ git push origin :dbg_lichen_star
也可以使用:
$ git push origin --delete dbg_lichen_star
這兩種方式都可以刪除指定的遠(yuǎn)程分支