Git 从远程拉取指定分支到本地

git remote add origin https://github.com/zion6135/CPP-study.git   // 添加操作的目的地网址

git fetch origin // 同步远程所有分支到本地

git fetch origin master  //仅同步远程master分支到本地

git branch -a //可以看到远程分支 origin/xxx

 

新建远程已有分支
git checkout -b new_branch origin/xxx // 新建分支new_branch同步远程分支origin/xxx

新建空白本地分支emptybranch,git push同步到远程(或者直接在git上新建分支,在同步远程分支)
git checkout --orphan emptybranch //创建emptybranch分支

git rm -rf . //会有当前分支所有东西,但无提交日志,需要清空

 

来源 :https://blog.csdn.net/m0_37844072/article/details/122713165

 

posted @ 2022-09-07 14:14  小琪子  阅读(1923)  评论(0)    收藏  举报