本文共 1585 字,大约阅读时间需要 5 分钟。
remove git
If you use , you're probably adding files all the time as you develop your project out further and further. Sometimes though, you might need to actually remove a file from the Git repository but not not from your local files. For example, say you forgot to add a file to .gitignore
but you don't want to remove it from your local development environment. This could be from a mistake or you didn't realize that a new package or something created a bunch of nasty log files you don't want in the repo. Either way, this is actually very easy to do.
如果使用 ,那么随着项目的不断发展,可能一直都在添加文件。 但是有时,您实际上可能需要从Git存储库中删除文件,而不是从本地文件中删除文件。 例如,假设您忘记将文件添加到.gitignore
但又不想将其从本地开发环境中删除。 这可能是由于错误造成的,或者您没有意识到新的程序包或某些东西创建了一些您不想在回购中使用的讨厌的日志文件。 无论哪种方式,这实际上都是很容易做到的。
This method will remove a single file from your Git repository without deleting the file from your local environment. Then when you run git push
, the files will be removed in the remote repo.
此方法将从您的Git存储库中删除一个文件,而不会从本地环境中删除该文件。 然后,当您运行git push
,文件将在远程仓库中删除。
git rm --cached filexample.txt
In a similar fashion, you can do this for multiple files at one time.
以类似的方式,您可以一次对多个文件执行此操作。
git rm --cached file1.txt file2.txt file3.txt
This also works recursively for folders so long that you add the -r
flag to the command. Here's an example:
只要您将-r
标志添加到命令中,这也可以递归地用于文件夹。 这是一个例子:
git rm -r --cached folder
翻译自:
remove git
转载地址:http://lnywd.baihongyu.com/