git rm - 缓存和致命:pathspec [英] git rm --cached and fatal: pathspec

查看:645
本文介绍了git rm - 缓存和致命:pathspec的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 错误:未经操作的工作树文件'app.xcodeproj / project.xcworkspace / xcuserdata / u.xcuserdatad / UserInterfaceState.xcuserstate'将被合并覆盖。 

所以,我试图从git中删除这个文件(我已经在.gitignore中添加了一个表达式使用:

  git rm --cached app.xcodeproj / project.xcworkspace / xcuserdata / u.xcuserdatad / UserInterfaceState .xcuserstate 

得到:

  fatal:pathspec'app.xcodeproj / project.xcworkspace / xcuserdata / u.xcuserdatad / UserInterfaceState.xcuserstate'不匹配任何文件

所以,有点损失。从我的理解,工作文件不是这里的问题。但是,为了完整性,工作文件确实存在。例如。

  ls -l app.xcodeproj / project.xcworkspace / xcuserdata / u.xcuserdatad / UserInterfaceState.xcuserstate 
-rw -r - r-- 1 uu 56061 24 Sep 12:42 app.xcodeproj / project.xcworkspace / xcuserdata / u.xcuserdatad / UserInterfaceState.xcuserstate


解决方案

所以,解决方案是这样的:



分支B



但它存在于我们试图检出的分支A中,所以我们得到一个警告,说明当前工作树中的文件将被覆盖即使我们没有跟踪它)



因此:
$ b $ ol

  • 删除现有目录中的文件(我刚将它移出​​工作树的某个地方,以保证安全)分支B


  • 检查分支需要 - 即分支A


  • 使用类似下面的方法从分支A中移除它:

    git rm - 缓存的app.xcodeproj / project.x cworkspace / xcuserdata / u.xcuserdatad / UserInterfaceState.xcuserstate


  • 注意:Fwiw,Branch A是我的主分支。分公司B是我的开发分支。


    I just tried to checkout my master branch and ran into:

    error: Untracked working tree file 'app.xcodeproj/project.xcworkspace/xcuserdata/u.xcuserdatad/UserInterfaceState.xcuserstate' would be overwritten by merge. 
    

    So, I tried to delete this file from git (I'd already added an expression in .gitignore to catch it) using:

    git rm --cached app.xcodeproj/project.xcworkspace/xcuserdata/u.xcuserdatad/UserInterfaceState.xcuserstate
    

    and got:

    fatal: pathspec 'app.xcodeproj/project.xcworkspace/xcuserdata/u.xcuserdatad/UserInterfaceState.xcuserstate' did not match any files 
    

    So, at a bit of a loss. From my understanding the working file isn't the issue here. However, for completeness, a working file does exist. E.g.

    ls -l app.xcodeproj/project.xcworkspace/xcuserdata/u.xcuserdatad/UserInterfaceState.xcuserstate
    -rw-r--r--  1 u  u  56061 24 Sep 12:42 app.xcodeproj/project.xcworkspace/xcuserdata/u.xcuserdatad/UserInterfaceState.xcuserstate
    

    解决方案

    So, the solution is this:

    The file is untracked in this current branch B

    But it exists in the branch we are trying to check out, branch A, so we get a warning that the file in our current working tree will be overwritten (even though we aren't tracking it)

    So:

    1. delete the file in your existing directory (I just moved it somewhere out of the working tree initially to be safe) of branch B

    2. check out the branch you want - i.e. branch A

    3. Remove it from branch A using something like this:

      git rm --cached app.xcodeproj/project.xcworkspace/xcuserdata/u.xcuserdatad/UserInterfaceState.xcuserstate

    Note: Fwiw, Branch A was my master branch. Branch B was my dev branch.

    这篇关于git rm - 缓存和致命:pathspec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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