Git工作流程:“您的本地更改将被合并覆盖” [英] Git workflow: "Your local changes would be overwritten by merge"

查看:1078
本文介绍了Git工作流程:“您的本地更改将被合并覆盖”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在三台服务器上与另一位开发人员合作:我的本地虚拟机
>开发服务器

  • 实时服务器

  • 我采用的工作流程是,在本地虚拟机上的所有工作,然后将修改后的资源从repomote资源库中提取到dev服务器(dev分支)和活动服务器(与dev分支合并后的master bean)。



    <不幸的是,另一位开发人员修改了一些文件,直接在活动服务器上安装Wordpress插件。因此,当我尝试在实时服务器上将 master 分支更新为远程重新采购时的 master 时,我收到了这样的消息:

     错误:您对'plugins / bulk-page-creator / bulk-page-合并将覆盖creator.php。中止。 

    请在进行合并之前提交您的更改或隐藏它们。



    我猜这些文件没有被跟踪。我真的想避免从我的本地虚拟机以外的服务器进行远程repo。



    这里我的opitons解决这个问题。我只需要将实时服务器上的代码库更新到远程仓库即可 - 就是这样。



    我是否应该放弃这些本地更改?



    我也试着同步代码库:

    git fetch
    git merge FEATCH_HEAD



    没有运气。

    我的选择在这里是什么? 你说得对,你得到这条消息是因为这些文件已经存在于本地,没有在当前签出的版本中跟踪,您试图合并的提交包含该文件。



    当Git已经知道文件在合并之前,它可以安全地同意覆盖它,但在这种情况下,您有机会获得该文件,并且不知道Git现在会覆盖它,所以Git根本就不会这么做。



    要解决此问题,您只需为Git腾出空间来执行合并。您可以通过两种简单的方法来完成此操作:


    1. 删除文件。这样,Git就可以在没有任何冲突的情况下从新提交中检出文件。
    2. 重命名文件。与上面相同,但您有机会恢复本地更改,以防您确保本地执行的所有操作都包含在跟踪文件中。


    I've been working with another developer across three servers:

    1. My local VM
    2. Dev server
    3. Live server

    The workflow that I adopted was to, obiously, do all the work on my local VM, then pull the changes form the repomote repository to the dev server (dev branch) and live server (master beanch after merging with dev branch).

    Unfortunately, another developer modified some files, install Wordpress plugins directly on the live server. Consequently, when I attempt to bring the master branch on the live server up to date with master on the remote reposiotry, I get messages like this one:

    Error: Your local changes to 'plugins/bulk-page-creator/bulk-page-creator.php' would be overwritten by merge.  Aborting.
    

    Please, commit your changes or stash them before you can merge.

    I guess that these files are not tracked. I really want to avoid commiting to the remote repo from a server other than my local VM.

    What are my opitons here to resolve this problem. I just need to bring the codebase on the live server up to date with the remote repo - that's it.

    Should I somehow discard these local changes?

    I also attempted to synchronize the codebase with:

    git fetch git merge FEATCH_HEAD

    with no luck.

    What are my options here?

    解决方案

    You are right, you get that message because the files already exist locally, are not tracked in the currently checked out version, and the commit you are trying to merge in contains the file.

    When Git already knows the file before the merge, then it can safely agree to overwrite it, but in this situation there is the chance that you have the file and don’t know that Git would now overwrite it, so Git simply won’t do it.

    To resolve this issue, you just need to make room for Git to perform the merge. You can do this in two simple ways:

    1. Delete the file. That way, Git will be able to check out the file from the new commit without any conflicts.
    2. Rename the file. Same as above, but you have the chance to recover your local changes in case you want to make sure that everything you did locally is also included in the tracked file.

    这篇关于Git工作流程:“您的本地更改将被合并覆盖”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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