[英]Remove directories and files from git repository and add to ignore list
I've got a .net solution directory (on OSX using a virtual machine) and just did a 我有一个.net解决方案目录(在OSX上使用虚拟机),只是做了一个
$ git add .
$ git commit
on the whole directory. 在整个目录上。
I forgot there were a number of file and directories I didn't want added, such as my _resharper directory, and the contents of my bin folder. 我忘了有一些我不想添加的文件和目录,比如我的_resharper目录,以及我的bin文件夹的内容。
So now, how do I first remove those directories and files from my local git repository without deleting them from my working copy? 那么现在,我如何首先从我的本地git存储库中删除这些目录和文件而不从我的工作副本中删除它们?
Additionally, how do I add said directories to an ignore list? 另外,如何将所述目录添加到忽略列表?
create a .gitignore file in the same directory as the repo. 在与repo相同的目录中创建.gitignore文件。 And put 并把
_resharper/
*file.cpp
*remember the slash after the directory name for folder names, no need asterisk *记住文件夹名称的目录名后面的斜杠,不需要星号
by the way, you will need to remove the folder, untrack and then put it back in if you already add and commited. 顺便说一下,如果你已经添加并提交,你将需要删除文件夹,未跟踪,然后将其重新放入。
git reflog
git reset @HEAD{x} # x depends on what you see in reflog
#edit .gitignore
#add line in gitignore
#_resharper/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.