git 分支 branch 操作


創建分支

git branch test: 基於當前commit創建test分支。.git/HEAD 文件中記錄了當前分支名字。

刪除分支

git branch -d test:刪除本地test分支

git branch -D test: test分支還沒有合入當前分支,所以要用-D參數才能刪掉。

git push origin --delete test 刪除遠程test分支

git push origin :test 刪除遠程test分支

查看分支

git branch 列出當前分支清單

git branch -a 查看遠程分支和本地分支

git branch -v 查看各個分支最后一個提交信息

git branch --merged 查看哪些分支已經合並入當前分支

拉取分支 

git fetch origin 同步遠程服務器的數據到本地

git checkout -b test origin/test_remote 將遠程分支test_remote拉取下來到本地test分支

git checkout test 將遠程分支test拉取下來到本地test分支

git pull test從遠程分支test 中checkout下來的本地分支test成為跟蹤分支,使用git pull或者git push就會操作到對應的遠程分支test

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM