如何清理回购,如果阶段性文件标记为修改?
后
git reset --hard
我得到
Encountered 7 file(s) that should have been pointers, but weren't:
运行git clean -fdx也没有帮助。
如何清理回购,如果阶段性文件标记为修改?
后
git reset --hard
我得到
Encountered 7 file(s) that should have been pointers, but weren't:
运行git clean -fdx也没有帮助。
当前回答
在我的例子中,它是一个lfs规则下的文件(我假设它是在没有安装lfs或其他东西的情况下检入的)。
所以我在.gitattributes文件中找到了它的扩展名,并将这一行注释为
#*.7z filter=lfs diff=lfs merge=lfs -text
保存这个.git属性,然后git状态显示没有问题。
之后,我取消了这一行的注释(删除了#),保存了.gitattributes和git状态仍然显示没有问题。
其他回答
这里有一个修饰,不需要重新安装lfs钩子或模糊任何.gitattributes文件:
git -c filter.lfs.smudge= -c filter.lfs.clean= reset --hard
当一个明显的错误突然出现时,我们的团队是这样做的:
Disable lfs for that specific type file (modifying .gitattributes or via SourceTree menus) The change will dissapear and you will see a change on .gitattributes instead Remove the problem: 3.1 One solution is to execute git reset --hard. Another way, discard changes. Sometimes the file will not come up again. 3.2.1 If the previous solution doesn't work, repeat 1 and 2. Then make sure that this branch you are in (A) has already commited and pushed everything except those annoying files. Then commit your change, but not push. 3.2.2: Go to another branch (B) 3.2.3: Remove that local branch (A) where you performed the commit to .gitattributes, forcing the removal even when it says there's a commit that hasn't been pushed. It will forget that commit (it can afterwards be removed via GC or whatever but it's not a big deal if the file that has the error is not huge) 3.2.4: Checkout the branch A again. It will download the previous status of the repository without the annoying files and LFS settings set up the correct way.
这招总是管用的!
在我的例子中,它是一个lfs规则下的文件(我假设它是在没有安装lfs或其他东西的情况下检入的)。
所以我在.gitattributes文件中找到了它的扩展名,并将这一行注释为
#*.7z filter=lfs diff=lfs merge=lfs -text
保存这个.git属性,然后git状态显示没有问题。
之后,我取消了这一行的注释(删除了#),保存了.gitattributes和git状态仍然显示没有问题。
在这个问题上有多个步骤来解决。
如果你只是处于一个破碎的状态,就像卡在一个分支上,因为你不能重置/丢弃对问题文件的更改:删除.gitattributes文件可能足以让你进行下一次git移动。一旦你移动了你的git,你可能需要恢复.gitattributes文件,但至少你摆脱了困境。
我希望我在尝试上述所有方法之前就知道这一点。至少尝试一下是一个低风险的选择。
这是我遇到的问题:
假设您创建了一个分支,并以某种方式将文件提交为非lfs。因此,您试图通过稍后在同一分支上提交文件的LFS版本来纠正它。然而,现在你不能重基或压缩,因为你会一直遇到这种“文件应该是指针,但不是”错误在重基中间。
解决使用git重置——软:https://stackoverflow.com/a/5201642/2516916