如何清理回购,如果阶段性文件标记为修改?
后
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没有跟踪这些文件,但是它们符合一些.gitattributes文件的描述。
例如,
服务器/ .gitattributes:
conf/** filter=lfs diff=lfs merge=lfs -text
server/conf/client.conf文件太大,被LFS跟踪 服务器/ conf /客户端。gflags是在git而不是LFS中跟踪的
然而,客户端。Gflags匹配服务器/。git会从LFS中拉出它,但是它没有LFS信息,错误就会被抛出。
解决方案
找到描述与encounter文件相匹配的.gitattributes文件,删除错误的描述或优化一些通配符匹配。
优化上面的例子, 服务器/ .gitattributes:
conf/client.conf filter=lfs diff=lfs merge=lfs -text
其他回答
下面的进程将添加一个提交,将所有应该是lfs指针的二进制文件替换为lfs指针。
Clean working copy completely. Together with the force add below this prevents any files getting added or removed due to .gitignore patterns. git clean -dfx git reset --hard git checkout -- . Add remove for everything to staging area. Working copy will not be touched. git rm --cached -r . Readd all files from working copy again. This will basically undo the previous command but will reevaluate lfs filters. Use -f to ignore .gitignore. All files present were previously checked in and should get added again. git add -f . You staging area now should only contain the binary files that previously raised the 'should have been pointers' error. git commit -m "moved files to lfs"
当一个明显的错误突然出现时,我们的团队是这样做的:
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.
这招总是管用的!
这只是再次显示什么一堆狗**** GIT-LFS。
你可能会遇到这种情况,如果:
文件包含在common-base-branch中,而不是LFS中 在基于common-base-branch的分支LFS -branch中,文件被移动到LFS 在另一个同样基于common-base-branch的非lfs-branch分支中,修改了文件。
或者:
文件不包含在common-base-branch中 在基于common-base-branch的分支LFS -branch中,文件被添加到LFS 在另一个同样基于common-base-branch的非LFS -branch分支中,文件被添加(但不是添加到LFS。
在这两种情况下,当您尝试将非lfs-branch合并到lfs-branch时,都会得到这种错误。
您可能会问,为什么会出现这种情况,但答案是,许多软件是由不止一个人开发的(这就是为什么会有像GIT这样的版本控制系统),而且人们并不总是彼此交谈,或者LFS是后来在一个特性分支的项目历史中引入的,而“正常”的开发仍然在其他分支中进行。
这是一种合法的合并冲突情况,而不是错误或损坏的工作目录或任何东西(正如其他一些答案所暗示的那样)。GIT-LFS只是处理得不好。
您现在要做的是确保冲突文件的正确版本进入GIT-LFS,因此您可能想要选择这个问题的答案…(注意事项:插入至少一个有效答案的链接)
在我的例子中,它是一个lfs规则下的文件(我假设它是在没有安装lfs或其他东西的情况下检入的)。
所以我在.gitattributes文件中找到了它的扩展名,并将这一行注释为
#*.7z filter=lfs diff=lfs merge=lfs -text
保存这个.git属性,然后git状态显示没有问题。
之后,我取消了这一行的注释(删除了#),保存了.gitattributes和git状态仍然显示没有问题。
上面的命令对我都没用,我在这里找到了答案
git status -s | cut -c 4- | xargs git update-index --assume-unchanged
rm .git/index && git reset