It’s important to note that when you do a fetch that brings down new remote-tracking branches, you don’t automatically have local, editable copies of them. In other words, in this case, you don’t have a new
serverfix
branch — you have only anorigin/serverfix
pointer that you can’t modify
-
推送本地分支到遠程(遠程沒有該分支)
git push <remote> <branch>
例如將本地
serverfix
分支推送到遠程,這樣遠程倉庫也有serverfix
分支了:git push origin serverfix
-
本地拉取遠程分支(本地沒有該分支):兩步走-先拉取再checkout
$ git fetch origin $ git checkout -b serverfix origin/serverfix
拉取遠程
serverfix
分支到本地的serverfix
分支 -
將本地已有分支與遠程已有分支建立track關係
如下在本地
serverfix
分支敲這個命令:將當前分支 與 遠程倉庫的serverfix
分支建立track關係$ git branch --set-upstream-to origin/serverfix Branch serverfix set up to track remote branch serverfix from origin. or 簡寫成: $ git branch -u origin/serverfix
-
其他命令
-
查看本地分支與遠程分支的track關係:
git branch -vv
$ git branch -vv iss53 7e424c3 [origin/iss53: ahead 2] Add forgotten brackets master 1ae2a45 [origin/master] Deploy index fix * serverfix f8674d9 [teamone/server-fix-good: ahead 3, behind 1] This should do it testing 5ea463a Try something new
-
遠程倉庫分支列表以及詳細
列表:
git ls-remote <remote>
詳細:
git remote show <remote>
-
刪除遠程倉庫的分支
git push origin --delete serverfix
-