carrots-admin-ajax icon indicating copy to clipboard operation
carrots-admin-ajax copied to clipboard

Git 如何 clone 非 master 分支的代码?

Open zhuangyin8 opened this issue 7 years ago • 0 comments

我们每次使用命令git clone https://github.com/marijnh/Eloquent-JavaScript.git或者通过Webstorm git clone 默认会把远程仓库整个给clone下来,但只会在本地默认创建一个master分支。如果最新的代码版本或者我们需要的代码版本不在 master 分支上,该如何获取非 master 分支的代码?

git-branch-e730b9fd

解决方法

如果代码已经 clone 到本地,那么直接在本地代码文件夹路径下使用命令

git branch -r #查看远程分支

git branch -a #查看所有分支

git-branch-8f12d76f

成功切换到3rd分支

zhuangyin8 avatar Oct 04 '17 04:10 zhuangyin8