git提交代码从reject到提交成功全过程
- 1. 问题重述
- 2. 解决过程
- 出现新问题:Your local changes to the following files would be overwritten by merge
- 出现新问题:Merging is not possible because you have unmerged files
- 出现新问题:SystemMeanageService爆红
- 出现新问题:You have not concluded your merge (MERGE_HEAD exists).
这里是不断发芽的山有木兮,希望这个帖子可以帮到你!
1. 问题重述
git提交出现“updates were rejected because a pushed branch tip is behind its remote”
git报错如下:
09:01:59.572: [LCIntelligenceFusionSystem] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/cxd:develop --tagserror: failed to push some refs to 'ssh://git.piesat.cn:27022/hezhipeng/LCIntelligenceFusionSystem.git'hint: Updates were rejected because a pushed branch tip is behind its remoteTo ssh://git.piesat.cn:27022/hezhipeng/LCIntelligenceFusionSystem.githint: counterpart. Check out this branch and integrate the remote changes!refs/heads/cxd:refs/heads/develop[rejected] (non-fast-forward)hint: (e.g. 'git pull ...') before pushing again.Donehint: See the 'Note about fast-forwards' in 'git push --help' for details.Updates were rejected because a pushed branch tip is behind its remote
2. 解决过程
pull之后,还是拒绝,好像不对
换个帖子
我要推送的不是master是develop,所以把master换成develop
接着我git pull
提示BaseEntity被change了。
出现新问题:Your local changes to the following files would be overwritten by merge
报错如下:
Your local changes to the following files would be overwritten by merge
解决办法:
根据是否要保存本地修改,有以下两种解决方案
1 保留修改
执行以下三条命令
git stash #封存修改git pull origin master git stash pop #把修改还原
注:
git stash
:备份当前工作区内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时,将当前工作区内容保存到Git栈中
git pull
:拉取服务器上当前分支代码
git stash pop
:从Git栈中读取最近一次保存的内容,恢复工作区相关内容。同时,用户可能进行多次stash操作,需要保证后stash的最先被取到,所以用栈(先进后出)来管理;pop取栈顶的内容并恢复
git stash list
:显示Git栈内的所有备份,可以利用这个列表来决定从那个地方恢复。
git stash clear
:清空Git栈
2 废弃修改
核心思想就是版本回退,具体命令如下
git reset --hard git pull origin master
不建议使用第二种。除非你再三确定不需要本地的修改了。
我们使用第一种方法
我查看一下状态
git status
尝试merge,发现无法合并,右下角显示merging develop
出现新问题:Merging is not possible because you have unmerged files
报错如下:
error: Merging is not possible because you have unmerged files.hint: Fix them up in the work tree, and then use 'git add/rm 'hint: as appropriate to mark resolution and make a commit.fatal: Exiting because of an unresolved conflict.
解决办法:
用git diff或者git status 查看哪些文件冲突,有冲突的会提示:
++<<<<<<< HEAD
++<<<<<<< new_branch
修改你的冲突的文件,修改完之后,保存。用git add xxx,把你修改的文件全部都添加进去。最后,用git commit -a -m ” 备注信息 ” 提交,完成。
出现新问题:SystemMeanageService爆红
删掉了里面的<<<之类的还是红色
在我不知道咋办的时候
弹出一个窗,我也不知道我怎么触发的
然后我就把SystemMeanageService回滚了,确实只有这个是爆红的
回滚之后,不在出现红色,尝试提交代码
还是尝试合并代码
出现新问题:You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you merge.
他的意思是我还有没提交的,想合并,需要自己提交
提交成功
去gitlab查看