如何撤消git checkout文件中未提交的更改?

编程入门 行业动态 更新时间:2024-10-10 21:22:01
本文介绍了如何撤消git checkout文件中未提交的更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

因此,我做了一个GIT状态,并注意到上演了许多应该被GIT忽略的文件,例如.gitignore,.htaccess和我的Drupal站点的设置文件.

So I did a GIT status and noticed a bunch of files that were staged that should have been ignored by GIT ignore, such as .gitignore, .htaccess, and settings files for my Drupal site.

我错误地使用了 git checkout< file> 而不是 git rm< file> 从临时区域中将其删除.虽然看起来可行,但我还是中断了网站.我想我现在明白了 git checkout 会还原我对这些文件所做的任何更改,对吗?更改未提交,因为最初不应该对它们进行跟踪.

I mistakenly used git checkout <file> instead of git rm <file> to remove them from the staging area. While it looked like it worked, I broke the website. I think I now understand that git checkout reverts any changes I've made to those files, correct? The changes weren't committed because they weren't supposed to be tracked in the first place.

应该如何使用 git checkout< file> (这是相反的意思),现在我可以撤消撤消操作,还是从这里去哪里?

How is git checkout <file> supposed to be used (what is the opposite of it) and ow can I undo the undo or where do I go from here?

推荐答案

根据git的文档此处:

重要的是要了解 git checkout-< file> 是一个危险的命令.您对该文件所做的任何更改均已消失– Git刚刚复制了另一个文件.除非使用此命令,否则不要使用您完全知道您不需要该文件.

It’s important to understand that git checkout -- <file> is a dangerous command. Any changes you made to that file are gone – Git just copied another file over it. Don’t ever use this command unless you absolutely know that you don’t want the file.

所以您不能撤消该命令.

So you can't undo this command.

更多推荐

如何撤消git checkout文件中未提交的更改?

本文发布于:2023-11-09 07:46:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571772.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中未   文件   git   checkout

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!