1 查看遠(yuǎn)程分支
[plain]view plaincopy
$?git?branch?-a
*?br-2.1.2.2
master
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
2 查看本地分支
[plain]view plaincopy
shuohailhl@SHUOHAILHL-PC?/f/ggg/jingwei?(br-2.1.2.2)
$?git?branch
*?br-2.1.2.2
master
3 創(chuàng)建分支
[plain]view plaincopy
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
線面是把分支推到遠(yuǎn)程分支
[plain]view plaincopy
$?git?push?origin?test
4 切換分支到test
[plain]view plaincopy
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)
[plain]view plaincopy
$?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 查看本地和遠(yuǎn)程分支 ?-a。前面帶*號的代表你當(dāng)前工作目錄所處的分支
[plain]view plaincopy
remotes/origin/HEAD?->?origin/master?#啥意思呢?
”在clone完成之后橘荠,Git 會(huì)自動(dòng)為你將此遠(yuǎn)程倉庫命名為origin(origin只相當(dāng)于一個(gè)別名屿附,運(yùn)行g(shù)it remote –v或者查看.git/config可以看到origin的含義),并下載其中所有的數(shù)據(jù)哥童,建立一個(gè)指向它的master 分支的指針挺份,我們用(遠(yuǎn)程倉庫名)/(分支名) 這樣的形式表示遠(yuǎn)程分支,所以origin/master指向的是一個(gè)remote branch(從那個(gè)branch我們clone數(shù)據(jù)到本地)“
這個(gè)是執(zhí)行 git remote -v 的結(jié)果贮懈,看出來origin其實(shí)就是遠(yuǎn)程的git地址的一個(gè)別名匀泊。
[plain]view plaincopy
$?git?remote??-v
origin??git@xxxx/jingwei.git?(fetch)
origin??git@xxxx/jingwei.git?(push)
[plain]view plaincopy
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 刪除遠(yuǎn)程版本
[plain]view plaincopy
git?push?origin?:br-1.0.0
[plain]view plaincopy
刪除遠(yuǎn)程分支
git?branch?-r?-d?origin/branch-name
git?push?origin?:branch-name