简体   繁体   English

有没有办法列出git储存库中的所有当前文件?

[英]Is there a way to list all current files in a git repository?

I recently created a git repository on my server. 我最近在服务器上创建了一个git存储库。 Unfortunately during my last commit and push I had accidentally added all of my object files and some other junk files by mistake. 不幸的是,在上一次提交和推送期间,我不小心将所有目标文件和其他一些垃圾文件误加了。 Now when I do a git pull on my server side project I get abort warnings about overwriting my object files etc and I have to go and delete all of the problem files. 现在,当我在服务器端项目上执行git pull时,会收到有关覆盖目标文件等的异常中止警告,我必须删除所有问题文件。 I want to delete all of these files from the respository using the git add -A . 我想使用git add -A .从存储库中删除所有这些文件git add -A . options once there are deleted and then committing (I think this is the right way to go). 选项一旦删除,然后提交(我认为这是正确的方法)。 So basically to ensure I get rid of everything, I would like a way to get a list of the files that will be pulled from the repository - is there a command that does this?? 因此,基本上可以确保我摆脱了一切,我想要一种获取将从存储库中提取的文件列表的方法-是否有执行此操作的命令?

You could reset HEAD to the commit before the commit that added everything and then do: git clean -xdf to discard everything from the working directory. 您可以在添加所有内容的提交之前将HEAD重置为提交,然后执行: git clean -xdf丢弃工作目录中的所有内容。 Warning: this will blow away all uncommitted files. 警告:这将吹走所有未提交的文件。 If that's not what you want, do not use git clean 如果这不是您想要的,请不要使用git clean

It doesn't make a sense. 这没有意义。 You should not care what was pulled. 您不应该在乎什么。 Git operates with a snapshots of the whole file tree. Git使用整个文件树的快照进行操作。 If you have committed files, the commit id is a1b2c3, and if any other working copy in any repo which has the commit a1b2c3 has exactly the same set of files. 如果已提交文件,则提交ID为a1b2c3,并且任何回购中具有提交a1b2c3的其他工作副本都具有完全相同的文件集。 (I assume you have clean working copy). (我假设您有干净的工作副本)。

So, you should change (remove) your files locally, commit and push your changes and checkout it on the server. 因此,您应该在本地更改(删除)文件,提交并推送更改并在服务器上签出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM