简体   繁体   English

引入功能分支而不会发生合并冲突

[英]Pull in feature branch without merge conflicts

I have a feature branch I am working on. 我有一个我正在研究的功能分支。 There is a test server that I ssh into and pull my feature branch from master. 我有一个测试服务器,从master中提取我的功能分支。 So throughout the day, I make changes on my feature branch and push them. 因此,我整天都在功能分支上进行更改并推送它们。 However, whenever I try out the changes on my test server by ssh'ing into , checking out master and then pulling my feature branch, I get merge conflicts each time. 但是,每当我通过ssh进入测试服务器上的更改,检查master服务器然后拉动我的功能分支时,每次都会遇到合并冲突。 The first few times, I manually resolved them but I get them every time now. 前几次,我手动解决了它们,但我现在每次都得到它们。 Is there any way to avoid this and to just have it overwrite them? 有没有办法避免这种情况,只是让它覆盖它们?

It sounds like your feature branch is behind your master branch. 听起来你的功能分支在你的主分支后面。 Try and push your master branch to your remote repository, pull your master branch to your local machine and create your new feature branch from the up-to-date master branch. 尝试将主分支推送到远程存储库,将主分支拉到本地计算机并从最新的主分支创建新功能分支。 When you're done with your feature, you should be able to push your new feature branch and pull it into master without getting merge conflicts. 完成功能后,您应该可以推送新功能分支并将其拉入主服务器而不会出现合并冲突。

Keep in mind that you would have to repeat the process above every time you update your master branch. 请记住,每次更新主分支时都必须重复上述过程。

A short-term solution to your last question, 对您上一个问题的短期解决方案,

"Is there any way to avoid this and to just have it overwrite them?" “有没有办法避免这种情况,只是让它覆盖它们?”

is to set the "theirs" option on the recursive merge strategy (the default merge strategy) when pulling from your feature branch, for example: git pull -Xtheirs origin feature-branch . 从提取功能分支时,在递归合并策略(默认合并策略)上设置“他们的”选项,例如: git pull -Xtheirs origin feature-branch

However , since you mentioned that it is a test server you want test your changes on, you might want to consider rather just checking your feature branch out as @eftshift0 mentioned and to reserve your master branch for features you've already tested. 但是 ,由于您提到它是一个测试服务器,您希望测试您的更改,您可能需要考虑只检查您提到的@ eftshift0的功能分支,并为您已经测试过的功能保留主分支。 To checkout your feature branch you could use git fetch && git checkout origin/feature-branch . 要检查您的功能分支,您可以使用git fetch && git checkout origin/feature-branch

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

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