赞
踩
多人协作开发使用版本控制难免会有冲突,在前端使用VSCode和Git过程中,就会遇到大大小小的冲突,有的merge一下,然后提交推送就可解决,有的是因为HEAD指针混乱造成,本地和远程分支拉取/合并问题。
出现这种情况的原因是,A、B两个人同时操作了一个版本(HEAD)文件,工具不知道选择哪一个,这样就会报冲突。
- 使用当前|使用传入|
-
- current program
- <<<<<<< HEAD
- b789
- =======
- b45678910
- >>>>>>> 6853e5ff961e684d3a6c02d4d06183b5ff330dcc
- incoming program
出现以下冲突页面后,在冲突代码上会有使用当前代码还是使用传入代码的选项,分析代码,选择留下有用的代码即可。
本地创建的分支或与远程分支失联的分支,pull代码或者提交代码就会报以下错误:
- You asked me to pull without telling me which branch you
- want to merge with, and 'branch.production.merge' in
- your configuration file does not tell me, either. Please
- specify which branch you want to use on the command line and
- try again (e.g. 'git pull <repository> <refspec>').
- See git-pull(1) for details.
-
- If you often merge with the same branch, you may want to
- use something like the following in your configuration file:
-
- [branch "debug"]
- remote = <nickname>
- merge = <remote-ref>
-
- [remote "<nickname>"]
- url = <url>
- fetch = <refspec>
-
- See git-config(1) for details.


本地分支和远程分支没有关联的解决方法就是使用--set --upstream跟踪远程分支即可。
我本地分支是local_branch 远程分支是origin/local_branch
在终端使用以下命令:
git branch --set --upstream origin/local_branch local_branch
正确的标识就是在左下角由云图标变成循环图标
现在本地和远程分支已经关联上,但是可能因为本地和远程失联太久,本地分支的HEAD已经关联不上远程的HEAD,本地pull代码也和远程不一致,这样就造成下面的问题:
你还没有结束你的合并(MERGE_HEAD存在)。退出,因为未完成合并。本地没有更新到最新代码,
解决方法有三个:
方法一:
- git merge --abort
- git reset --merge
- git pull
- git fetch --all
- git reset --hard origin/master
- git fetch
【已解决】github中git push origin master出错:error: failed to push some refs to
You have not concluded your merge (MERGE_HEAD exists)
祝好运^_^
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。