1 查看遠程分支java
$ git branch -a git
* br-2.1.2.2 gitlab
master fetch
remotes/origin/HEAD -> origin/master spa
remotes/origin/br-2.1.2.1 指針
remotes/origin/br-2.1.2.2 orm
remotes/origin/br-2.1.3 server
remotes/origin/master rem
2 查看本地分支cmd
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git branch
* br-2.1.2.2
master
3 建立分支
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git branch test
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git branch
* br-2.1.2.2
master
test
線面是把分支推到遠程分支
$ git push origin test
4 切換分支到test
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git branch
* br-2.1.2.2
master
test
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git checkout test
M jingwei-server/src/main/java/com/taobao/jingwei/server/service/cmd/GetCustomerTarCmd.java
M jingwei-server/src/main/java/com/taobao/jingwei/server/util/ServerUtil.java
Switched to branch 'test'
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (test)
$ git branch
br-2.1.2.2
master
* test
M 表示cong 原來分支(上一次修改沒有提交br-2.1.2.2)帶過來的修改
5 刪除本地分支 git branch -d xxxxx
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (test)
$ git checkout br-2.1.2.2
M jingwei-server/src/main/java/com/taobao/jingwei/server/service/cmd/GetCustomerTarCmd.java
M jingwei-server/src/main/java/com/taobao/jingwei/server/util/ServerUtil.java
Switched to branch 'br-2.1.2.2'
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git br
* br-2.1.2.2
master
test
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git br -d test
Deleted branch test (was 17d28d9).
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (br-2.1.2.2)
$ git br
* br-2.1.2.2
master
6 查看本地和遠程分支 -a。前面帶*號的表明你當前工做目錄所處的分支
remotes/origin/HEAD -> origin/master #啥意思呢?
」在clone完成以後,Git 會自動爲你將此遠程倉庫命名爲origin(origin只至關於一個別名,運行git remote –v或者查看.git/config能夠看到origin的含義),並下載其中全部的數據,創建一個指向它的master 分支的指針,咱們用(遠程倉庫名)/(分支名) 這樣的形式表示遠程分支,因此origin/master指向的是一個remote branch(從那個branch咱們clone數據到本地)「
這個是執行 git remote -v 的結果,看出來origin其實就是遠程的git地址的一個別名。
$ git remote -v
origin git@gitlab.alibaba-inc.com:middleware/jingwei.git (fetch)
origin git@gitlab.alibaba-inc.com:middleware/jingwei.git (push)
shuohailhl@SHUOHAILHL-PC /f/ggg/jingwei (test)
$ git branch -a
br-2.1.2.2
master
* test
remotes/origin/HEAD -> origin/master
remotes/origin/br-2.1.2.1
remotes/origin/br-2.1.2.2
remotes/origin/br-2.1.3
remotes/origin/master
7 刪除遠程版本
git push origin :br-1.0.0