git切换远程分支

git切换远程分支_第1张图片

1、查看远程分支

git branch -a

例子:

$git branch -a
* master
  remotes/origin/TMP
  remotes/origin/HEAD -> origin/master
  remotes/origin/AA
  remotes/origin/BB

2、切换到指定的远程分支

git checkout -b tmp origin/TMP

上方命令的含义:在本地创建tmp分支,并从远程branch origin/TMP拉取

例子:

$git checkout -b TMP origin/TMP
Updating files: 100% (19896/19896), done.
Branch 'TMP' set up to track remote branch 'TMP' from 'origin'.
Switched to a new branch 'TMP'

注意:若需要切换到他人新创建的branch上,需将当前目录git pull, 否则无法切换分支。git branch -a时看不到新的远程分支。

你可能感兴趣的:(工作经验分享,git,github)