Search code examples
gitmergeterminalconflict

Conflict merging local into develop environment


So because I little mistake i made im having conflicts merging my local files into my develop environment.

I was working on maintenance on a Wordpress website. I do this by first testing the updates out on a local environment than push it to the develop environment but i accidently updated few plugins in the dev environment without noticing. when i noticed i switched to the local one and did the updates there now when i want to merge the local files into the dev environment i get this error in my terminal.

> * branch            develop    -> FETCH_HEAD
Updating f08f8fb..c72a8b7
error: The following untracked working tree files would be overwritten by merge:
    wp-content/plugins/redirection/api/api.php
    wp-content/plugins/redirection/redirection-capabilities.php
    wp-content/plugins/w3-total-cache/BrowserCache_Environment_Nginx.php
    wp-content/plugins/w3-total-cache/BrowserCache_Page_View_SectionSecurity.php
    wp-content/plugins/w3-total-cache/Cdn_Environment_Nginx.php
    wp-content/plugins/w3-total-cache/Extension_Amp_Page_View.php
    wp-content/plugins/w3-total-cache/Generic_Page_PurgeLog.php
    wp-content/plugins/w3-total-cache/Generic_Page_PurgeLog_View.php
    wp-content/plugins/w3-total-cache/LazyLoad_Mutator.php
    wp-content/plugins/w3-total-cache/LazyLoad_Mutator_Picture.php
    wp-content/plugins/w3-total-cache/LazyLoad_Mutator_Unmutable.php
    wp-content/plugins/w3-total-cache/ObjectCache_Page_View_PurgeLog.php
    wp-content/plugins/w3-total-cache/Util_DebugPurgeLog_Reader.php
    wp-content/plugins/wordfence/css/activity-report-widget.1579191227.css
    wp-content/plugins/wordfence/css/diff.1579191227.css
    wp-content/plugins/wordfence/css/dt_table.1579191227.css
    wp-content/plugins/wordfence/css/fullLog.1579191227.css
    wp-content/plugins/wordfence/css/iptraf.1579191227.css
    wp-content/plugins/wordfence/css/jquery-ui-timepicker-addon.1579191227.css
    wp-content/plugins/wordfence/css/jquery-ui.min.1579191227.css
    wp-content/plugins/wordfence/css/jquery-ui.structure.min.1579191227.css
    wp-content/plugins/wordfence/css/jquery-ui.theme.min.1579191227.css
    wp-content/plugins/wordfence/css/main.1579191227.css
    wp-content/plugins/wordfence/css/phpinfo.1579191227.css
    wp-content/plugins/wordfence/css/wf-adminbar.1579191227.css
    wp-content/plugins/wordfence/css/wf-colorbox.1579191227.css
    wp-content/plugins/wordfence/css/wf-font-awesome.1579191227.css
    wp-content/plugins/wordfence/css/wf-global.1579191227.css
    wp-content/plugins/wordfence/css/wf-ionicons.1579191227.css
    wp-content/plugins/wordfence/css/wf-onboarding.1579191227.css
    wp-content/plugins/wordfence/css/wf-roboto-font.1579191227.css
    wp-content/plugins/wordfence/css/wfselect2.min.1579191227.css
    wp-content/plugins/wordfence/css/wordfenceBox.1579191227.css
    wp-content/plugins/wordfence/js/Chart.bundle.min.1579191227.js
    wp-content/plugins/wordfence/js/admin.1579191227.js
    wp-content/plugins/wordfence/js/admin.ajaxWatcher.1579191227.js
    wp-content/plugins/wordfence/js/admin.liveTraffic.1579191227.js
    wp-content/plugins/wordfence/js/date.1579191227.js
    wp-content/plugins/wordfence/js/jquery-ui-timepicker-addon.1579191227.js
    wp-content/plugins/wordfence/js/jquery.colorbox-min.1579191227.js
    wp-content/plugins/wordfence/js/jquery.colorbox.1579191227.js
    wp-content/plugins/wordfence/js/jquery.dataTables.min.1579191227.js
    wp-content/plugins/wordfence/js/jquery.qrcode.min.1579191227.js
    wp-content/plugins/wordfence/js/jquery.tmpl.min.1579191227.js
    wp-content/plugins/wordfence/js/jquery.tools.min.1579191227.js
    wp-content/plugins/wordfence/js/knockout-3.3.0.1579191227.js
    wp-content/plugins/wordfence/js/wfdashboard.1579191227.js
    wp-content/plugins/wordfence/js/wfdropdown.1579191227.js
    wp-content/plugins/wordfence/js/wfglobal.1579191227.js
    wp-content/plugins/wordfence/js/wfpopover.1579191227.js
    wp-content/plugins/wordfence/js/wfselect2.min.1579191227.js
    wp-content/plugins/wordfence/modules/login-security/css/admin-global.1579191227.css
    wp-content/plugins/wordfence/modules/login-security/css/admin.1579191227.css
    wp-content/plugins/wordfence/modules/login-security/css/colorbox.1579191227.css
    wp-content/plugins/wordfence/modules/login-security/css/font-awesome.1579191227.css
    wp-content/plugins/wordfence/modules/login-security/css/ionicons.1579191227.css
    wp-content/plugins/wordfence/modules/login-security/css/jquery-ui-timepicker-addon.1579191227.css
    wp-content/plugins/wordfence/modules/login-security/css/jquery-ui.min.1579191227.css
    wp-content/plugins/wordfence/modules/login-security/css/jquery-ui.structure.min.1579191227.css
    wp-content/plugins/wordfence/modules/login-security/css/jquery-ui.theme.min.1579191227.css
    wp-content/plugins/wordfence/modules/login-secu
Aborting

Solution

  • You have untracked files that your incoming local branch are trying to write. Because when you try to overwrite files, the old one will be gone for good after the overwrite, and git is very good at detecting those conflict and made an effort to warn you to prevent any data loss.

    If you really mean it by "accidentally", it should be pretty much okay to overwrite them with your local branch. On dev environment, you can first dicard any changes you made

    git ls-files --others --exclude-standard | xargs rm -rf
    

    This will remove all of those untracked files. You can then merge your local branch again.