git合并不合并 [英] git merge does not merge

查看:86
本文介绍了git合并不合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主人和PersonalSite分支,用于我正在处理的代码库。我一再试图将主人合并到PersonalSite分支中无济于事。



这一次,我想我已经把所有东西都弄清楚了,所以我这样做了:

  git checkout master 
git pull
git checkout PersonalSite
git pull
git merge master

它看起来像一切正常,它列出了我预期的一组文件,但是存在冲突。冲突是正确的,如预期的那样,所以我修正了它,做了git add,git commit,然后是git push。但是现在,当我查看我的git日志时,它只显示了一个没有代码更改但只有一次冲突的提交。



现在,当我从PersonalSite分支运行git merge master时,它说已经是最新的。但事实并非如此,因为我尝试合并的变化实际上并未进行合并。我到底该怎么做才能让master实际合并到目前为止?解决方案

通过修复冲突并提交合并冲突,已经完成合并。必要时Git会添加合并提交,这是正常的,但它们不记录任何内容,除非合并发生并且在发生冲突时合并了哪些文件。如果你仔细看看你的日志,你会发现实际上有来自主人的提交。

编辑:
好​​的,试试这个测试。您不必使用合并命令,您可以将主人拉入PersonalSite。

  git checkout PersonalSite 
git pull origin master

查看给出的是什么。如果它说最新,那么你已经正确合并。

如果您像本地合并本地资料,那么您需要确保本地跟踪分支是最新的。

  git pull origin master 
git pull origin PersonalSite


I have a master and "PersonalSite" branch for a codebase I'm working on. I have been repeatedly trying to merge the master into the PersonalSite branch to no avail.

This time, I thought I had everything straightened out, so I did:

git checkout master
git pull
git checkout PersonalSite
git pull
git merge master

It looked like everything was working, and it listed the set of files I would have expected, but there was a conflict. The conflict was correct and was as expected, so I fixed it, did "git add", "git commit", then "git push". But now, when I look at my git log, it just shows a commit with no code changes but a single conflict.

Now, when I run "git merge master" from the "PersonalSite" branch it says "Already up-to-date." but this clearly is not the case, as none of the changes I tried to merge actually merged. What exactly do I do to get master to actually merge at this point?

解决方案

By fixing the conflict and committing the merge conflict you've already completed the merge. Git adds merge commits when necessary, it's normal but they don't record anything except that the merge took place and what files were merged if there was a conflict. If you look more closely at your log you'll see there are in fact commits from master.

EDIT: Okay, try this a test. You don't have to use the merge command, you can just pull master into PersonalSite.

git checkout PersonalSite
git pull origin master

See what gives you. If it says up to date then you have merged correctly.

If you merge stuff locally like you did, then you need to ensure the local tracking branches are up to date. Always specify the branch name to pull from,

git pull origin master
git pull origin PersonalSite

这篇关于git合并不合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆