美文网首页我爱编程
untracked working tree files wou

untracked working tree files wou

作者: 崔盛希 | 来源:发表于2018-04-11 13:36 被阅读135次

    出现error: The following untracked working tree files would be overwritten by checkout

    屏幕快照 2018-04-11 下午1.33.11.png

    最近在做项目突然有次提交出现的问题:

    出现error: The following untracked working tree files would be overwritten by checkout

    *** $ git clean -d -fx


    屏幕快照 2018-04-11 下午1.34.38.png

    最后觉得不妥,还是找找有什么好的解决方案没有:

    方案1:
    git clean -d -fx ""
    其中
    x -----删除忽略文件已经对git来说不识别的文件
    d -----删除未被添加到git的路径中的文件

    f -----强制运行

    方案2:

    今天在服务器上git pull是出现以下错误:

    error: Your local changes to the following files would be overwritten by merge:

        application/config/config.php
    
        application/controllers/home.php
    

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

    Aborting

    不知道什么原因造成的代码冲突,处理方法如下:

    如果希望保留生产服务器上所做的改动,仅仅并入新配置项:

    git stash

    git pull

    git stash pop

    然后可以使用git diff -w +文件名 来确认代码自动合并的情况.

    如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:

    git reset --hard

    git pull

    方案3:

    1. [root@gitserver /data/work/www/rest/lib/Business/Inventory]# git pull

    2. Enter passphrase for key '/root/.ssh/id_rsa':

    3. Updating 70e8b93..a0f1a6c

    4. error: Your local changes to the following files would be overwritten by merge:

    5. rest/lib/Business/Inventory/ProductStatus.php

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

    7. Aborting

    8. [root@gitserver /data/work/www/rest/lib/Business/Inventory]# git checkout -f

    9. Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded.

    10. [root@gitserver /data/work/www/rest/lib/Business/Inventory]# git pull

    11. Enter passphrase for key '/root/.ssh/id_rsa':

    12. Updating 70e8b93..a0f1a6c

    13. Fast-forward

    14. rest/lib/Business/Inventory/ProductStatus.php | 1 +

    15. 1 files changed, 1 insertions(+), 0 deletions(-)

    16. mode change 100644 => 100755 rest/lib/Business/Inventory/ProductStatus.php

    17. $ git pull

    18. Password:

    19. You asked me to pull without telling me which branch you

    20. want to merge with, and 'branch.master.merge' in

    21. your configuration file does not tell me, either. Please

    22. specify which branch you want to use on the command line and

    23. try again (e.g. 'git pull <repository> <refspec>').

    24. See git-pull(1) for details.

    25. If you often merge with the same branch, you may want to

    26. use something like the following in your configuration file:

    27. [branch "master"]

    28. remote = <nickname>

    29. merge = <remote-ref>

    30. [remote "<nickname>"]

    31. url = <url>

    32. fetch = <refspec>

    33. See git-config(1) for details.

    34. git remote add -f origin git@192.168.21.44:rest.git

    35. git config branch.master.remote origin

    36. git config branch.master.merge refs/heads/master

    再重新提交就把问题解决了。
    QQ:1300000608
    欢迎交流!

    相关文章

      网友评论

        本文标题:untracked working tree files wou

        本文链接:https://www.haomeiwen.com/subject/ydwahftx.html