简体   繁体   English

Git撤消作为.gitignore一部分的文件夹的更改

[英]Git undo a change in a folder that was a part of .gitignore

I am building a theme for NodeBB and the theme lives inside the node_modules directory. 我正在为NodeBB构建一个主题,主题位于node_modules目录中。 Pulling in from master last night I have a new .gitignore my file had ignore all node_modules except for my theme, well since this is a new .gitignore it didn't track my changes. 昨晚从主人那里拉进来我有一个新的.gitignore我的文件忽略了除我的主题之外的所有node_modules ,因为这是一个新的.gitignore它没有跟踪我的更改。

Then I made changes to my theme without it being tracked. 然后我对我的主题进行了更改而没有被跟踪。 I decided to merge with my repo, after some conflicts took a step back then did npm prune now this pruned my theme, I spent the last hour making changes that I am not sure I can get back. 我决定合并我的回购,在一些冲突后npm prune然后npm prune现在这修剪了我的主题,我花了最后一小时进行更改,我不确定我能回来。

My question is since the folder was not being tracked is it possible to undo the npm prune and recover the theme within node_modules ? 我的问题是,由于没有跟踪文件夹,是否可以撤消npm prune并恢复node_modules的主题?

Sadly, I think you won't be able to get your files back. 可悲的是,我认为你将无法恢复你的文件。

If you added the files or the directories to .gitignore, then git wasn't tracking them. 如果您将文件或目录添加到.gitignore,则git不会跟踪它们。 So you cannot get them back with git, unless you used to have them in the repo, but even if you did, the latest changes that you lost would not be part of the repo. 所以你不能用git取回它们,除非你曾经把它们放在回购中,但即使你这样做了,你丢失的最新变化也不会成为回购的一部分。 Sorry for the negative answer. 对不起,否定的答案。

However, all is probably not lost right now. 但是,现在可能都没有丢失。 If you immediately unmounted the file system or remounted it read-only as soon as you realised you deleted your theme, you could always try a file recovery tool such as photorec . 如果您立即卸载文件系统或在您意识到删除主题时将其重新安装为只读,则可以随时尝试文件恢复工具,例如photorec

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

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