从git拉取指定分支
- 先clone下来
git clone https://git.coding.net/zhoudafu/gblog.git
- 增加远程仓库(此步可省略,若添加远层仓库可参考)
git remote add origin https://git.coding.net/zhoudafu/gblog.git
- fetch下分支代码
git fetch origin coding-pages
- 使用checkout切换分支
git checkout -b coding-pages origin/coding-pages
分支 gh-pages 设置为跟踪来自 origin 的远程分支 coding-pages。切换到一个新分支 'coding-pages'
注:创建分支: git branch mybranch
切换分支: git checkout mybranch
创建并切换分支: git checkout -b mybranch
- 使用git status,add,commit,push origin gh-pages正常提交
本地创建分支并提交到远程分支
- 从已有的分支创建新的分支(如从master分支),创建一个gh-pages分支,执行完成自动切换到gh-pages分支,可使用git branch查看和切换
git checkout -b coding-pages
- 提交到远程仓库
git push origin coding-pages
添加多远程仓库 并拉取,合并,提交其他远程仓库代码
1823 git remote add origin2 https://github.com/yan-chou-strong/blog.git
1824 git fetch origin2 master