1、获取远程分支列表
git remote update origin --prune
2、merge远程分支(本地分支已经存在,如本地分支名称为:mybranch_20181017)
merge远程分支 如:origin/remotebranch_20181016
格式为 git merge 本地分支:远程分支
git merge mybranch_20181017:origin/remotebranch_20181016
3、将远程分支拉取到本地(本地分支不存在)
远程分支:origin/remotebranch_20181016
git checkout -b 本地分支:远程分支
git checkout -b mybranch20181017:origin/remotebranch20181016
如果出现以下提示
fatal: Cannot update paths and switch to branch 'dev2' at the same time.
Did you intend to checkout 'origin/dev2' which can not be resolved as commit?
表示远程拉取不成功,先执行一下语句
git fetch
4、将本地分支(mybranch_20181017)创建一个新的分支(mybranch_20181017_new)
git checkout -b 新分支名称
git checkout -b mybranch_20181017_new
5、拉取远程分支(mybranch_20181017)到本地分支(mybranch_20181017)
git pull origin 远程分支:本地分支
git pull origin mybranch_20181016:mybranch_20181017
6、提交本地分支(mybranch_20181017)到远程分支(mybranch_20181016)
git push origin 远程分支:本地分支
git branch origin mybranch_20181016:mybranch_20181017