1 查看遠程分支
1 $ git branch -a 2 * br-2.1.2.2 3 master 4 remotes/origin/HEAD -> origin/master 5 remotes/origin/br-2.1.2.1 6 remotes/origin/br-2.1.2.2 7 remotes/origin/br-2.1.3 8 remotes/origin/master
2 查看本地分支
3 創建分支
下面是把分支推到遠程分支
$ 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。前面帶*號的代表你當前工作目錄所處的分支
”在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
