日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

玩转GIT系列之【git的分支操作(查看分支/切换分支/新建分支/删除分支)】

發布時間:2023/12/15 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 玩转GIT系列之【git的分支操作(查看分支/切换分支/新建分支/删除分支)】 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、查看分支

1、查看全部分支

git branch -a

2、查看本地分支

git branch -l

3、查看遠程分支

git branch -r

二、切換分支

假設本地當前處于master分支下,遠端有一個test1分支和一個test2分支,想要切換到test1這個分支,怎么辦?

git branch -a * masterremotes/origin/HEAD -> origin/masterremotes/origin/test1remotes/origin/test2remotes/origin/master

可以使用以下兩個命令中的任何一個:

git checkout test1 git checkout -b test1 remotes/origin/test1

請注意:checkout命令如果使用了-b的語法,則一定要攜帶一個遠端分支作為參數,否則,該命令的執行效果就變成了:在本地新建一個分支,基于master分支,但是與遠端的test1分支并無任何關系。

以下是上述各個命令的執行效果:

git checkout test1 Branch test1 set up to track remote branch test1 from origin. Switched to a new branch 'test1'git checkout -b test1 remotes/origin/test1 Branch test1 set up to track remote branch test1 from origin. Switched to a new branch 'test1'git checkout -b test1 Switched to a new branch 'test1'

請自行仔細對比上述3個命令之間的差異!!!

三、新建分支

1、創建分支

git branch name

2、切換分支

git checkout name

3、創建+切換分支

git checkout -b name

四、刪除分支

1、刪除本地分支

git branch -d branch_name git branch -D branch_name

2、刪除遠程分支

git push origin :branch_name

請注意:origin后面有一個空格

五、重命名分支

git branch (-m | -M) <oldbranch> <newbranch>

重命名oldbranch為newbranch,使用-M則表示強制重命名。

如果你需要重命名遠程分支,推薦的做法是:
1、刪除遠程待修改分支;
2、push本地新分支名到遠程;

六、待添加

總結

以上是生活随笔為你收集整理的玩转GIT系列之【git的分支操作(查看分支/切换分支/新建分支/删除分支)】的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。