1.创建一个本地分支,并与远程分支建立联系:git checkout -b b origin/b
2.将远程代码pull到本地git pull origin b
报错:fatal:‘origin’ does not appear to be a git repository
fatal:Could not read from remote repository
原因:本地分支和远程分支断开连接
git fetch下拉所有分支
详情参照:https://blog.csdn.net/huanhuaqian/article/details/81986064
3.返回到你的分支a :git checkout a
4.合并分支a与分支b:git merge b
报错:git无法merge仓库refusing to merge unrelated histories
解决:在命令后面加: --allow-unrelated-histories
报错:git合并的时候,冲突问题Merging is not possible because you have unmerged files
解决:修改你的冲突的文件,修改完之后,保存。
用git add xxx,把你修改的文件全部都添加进去。
最后,用git commit -a -m ” 备注信息 ” 提交,完成。
5.把本地的分支a同步到远程: git push origin a
git push 成功,但是远程分支没有更新
git status 出现
On branch dev_master
Your branch is ahead of ‘origin/master’ by 4 commits.
(use “git push” to publish your local commits)
nothing to commit, working tree clean
git push出现
fatal: The upstream branch of your current branch does not match
the name of your current branch. To push to the upstream branch
on the remote, use
git push origin HEAD:master
To push to the branch of the same name on the remote, use
git push origin HEAD
To choose either option permanently, see push.default in ‘git help config’.
git push origin HEAD:master