博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
remove git_如何使用“ git Remove”而不删除文件
阅读量:2511 次
发布时间:2019-05-11

本文共 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但又不想将其从本地开发环境中删除。 这可能是由于错误造成的,或者您没有意识到新的程序包或某些东西创建了一些您不想在回购中使用的讨厌的日志文件。 无论哪种方式,这实际上都是很容易做到的。

使用Git删除单个文件而不删除它 ( Removing a single file with Git without deleting it )

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

使用Git删除多个文件而不删除它们 ( Removing multiple files with Git without deleting them )

In a similar fashion, you can do this for multiple files at one time.

以类似的方式,您可以一次对多个文件执行此操作。

git rm --cached file1.txt file2.txt file3.txt

删除整个目录而不删除文件 ( Removing an entire directory without deleting the files )

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/

你可能感兴趣的文章
Maven配置
查看>>
HttpServletRequest /HttpServletResponse
查看>>
SAM4E单片机之旅——24、使用DSP库求向量数量积
查看>>
从远程库克隆库
查看>>
codeforces Unusual Product
查看>>
hdu4348 - To the moon 可持久化线段树 区间修改 离线处理
查看>>
springMVC中一个class中的多个方法
查看>>
Linux系统安装出错后出现grub rescue的修复方法
查看>>
线段树模板整理
查看>>
[教程][6月4日更新]VMware 8.02虚拟机安装MAC lion 10.7.3教程 附送原版提取镜像InstallESD.iso!...
查看>>
[iOS问题归总]iPhone上传项目遇到的问题
查看>>
Python天天美味(总) --转
查看>>
Spring Framework tutorial
查看>>
【VS开发】win7下让程序默认以管理员身份运行
查看>>
【机器学习】Learning to Rank 简介
查看>>
Unity 使用实体类
查看>>
【转】通过文件锁实现,程序开始运行时,先判断文件是否存在,若存在则表明该程序已经在运行了,如果不存在就用open函数创建该文件,程序退出时关闭文件并删除文件...
查看>>
MySQL常见注意事项及优化
查看>>
流畅的Python (Fluent Python) —— 前言
查看>>
Jquery-menu-aim流畅的菜单滑动体验
查看>>