admin管理员组

文章数量:1612140

git合并代码出现的状况

合并完代码并上传远程分支时发现出现以下报错

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details
大致意思是:当前分支落后,先使用git pull下拉代码。
可能出现的原因是,有人上传代码的时候,把代码提交到主分支上,而你在合并代码的时候,又没有先使用git pull更新你主分支,直接合并代码,等提交才发现出错了。

当出错以后用git pull下拉代码

发现出现另外一个问题提示下图的提示

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/<branch> dev

大致意思是:你要指定pull那个分支的
所以你要用git pull origin 分支

git pull以后可能出现下面的情况

git pull以后,你在提交到远程分支可能会有下面图片的提示:

这个意思就是说,你要编辑一下合并的必要性。
可以不用写内容
只用执行以下步骤即可解决问题
第一步: 点击i
第二步: 点击Esc
第三步:输入:wq
第四步:点击Enter
即可完成

最后再次提交到主分支即可解决本问题

本文标签: informationTrackingbranchCurrent