简体   繁体   English

解决两个分支之间的冲突

[英]Resolve Conflicts Between Two Branches

I'm working on an application and managing its repo on bitbucket. 我正在开发一个应用程序,并在bitbucket上管理其回购。

During the development process, I created a new branch 'price-module' a few days ago and pushed its changes in the remote branch by the same name. 在开发过程中,几天前我创建了一个新的分支“价格模块”,并将其更改以相同的名称推送到远程分支中。 Now, when I'm merging 'price-module' to 'master' branch, bitbucket is showing me an error that there are conflicts between some files. 现在,当我将“价格模块”合并到“主”分支时,bitbucket向我显示一个错误,指出某些文件之间存在冲突。 (specifically in bin/R.txt). (特别是在bin / R.txt中)。 How can I resolve these conflicts and merge the changes I did in 'price-module' to 'master' branch without losing my code? 如何解决这些冲突,并将在“价格模块”中所做的更改合并到“主”分支中而又不会丢失代码?

PS: the project I'm working on is an Android project. PS:我正在处理的项目是一个Android项目。

Update: what have I tried so far to solve the problem 更新:到目前为止,我已尝试解决该问题的方法

I did some research on my own to try and solve the conflict between files. 我自己进行了一些研究,以尝试解决文件之间的冲突。 These are the steps I took to solve the conflict: 这些是我为解决冲突而采取的步骤:

  • Switched to master branch, manually overridden the conflicted files by copying them from 'price-module' branch (they are mainly gen or bin ), pushed them to master and then tried to merge 'price-module' into 'master' -- FAILED! 切换到master分支,通过从'price-module'分支(它们主要是genbin )复制它们来手动覆盖冲突的文件,将它们推送到master,然后尝试将'price-module'合并为'master'-FAILED !
  • Added Android-specific rules in exclude file in my .git folder from this answer but the gen and bin folders kept showing up. 此答案中,我的.git文件夹中的exclude文件中添加了特定于Android的规则,但genbin文件夹一直显示。

In an Android project, you should not be storing the bin folder in version control in the first place as it contains only generated files. 在Android项目中,首先不应将bin文件夹存储在版本控制中,因为它仅包含生成的文件。 Though R.txt isn't one of them, there's R.java in gen/your/package/name . 尽管R.txt不是其中之一,但是gen/your/package/nameR.java

Assuming it's the generated bin folder, you should remove it from git, add it to .gitignore so it doesn't show up as non-versioned in git status, merge or re-apply the deletion to both branches, and just let the build tools generate bin files as needed. 假设它是生成的bin文件夹,则应将其从git中删除,将其添加到.gitignore这样它就不会在git状态下显示为非版本化,将删除合并或重新应用到这两个分支,然后让构建工具会根据需要生成bin文件。

For more things to not put in version control, see Typical .gitignore file for an Android app 有关不要放入版本控制的更多信息,请参阅Android应用程序的典型.gitignore文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM