文件夹去掉git版本控制_从 git 版本控制中删除文件而不删除硬盘中文件

Git 学习笔记 —- 从 git 移除文件而不删除硬盘中的文件,你可能遇到过不小心将一个不需要的文件,或者另外一个重要的包含私密配置的文件添加到了 git 版本库中,这个时候你想从版本库中将其删除,而又不想影响到本地的文件,这个时候就需要使用到本文中需要使用到的内容。

从版本库中移除一个文件,停止对该文件的版本控制

The git rm command will allows you to remove a file from git control. The –cached option to git remove allows you to leave it on your hard drive.

Every once in awhile a file gets checked into git that isn’t supposed to be there. Common examples are configuration files, project files generated by your IDE with personal settings and even the occasional object file that someone decided to check in. These files are needed, so often you can’t delete them entirely and the process of copying them somewhere else, removing them from git and then replacing is painful, not to mention prone to error.

By adding the –cached option to the git rm command, you are able to remote the file file from git control while keeping the file in your working tree. They command syntax is:

git rm --cached file

Git will no longer track this file even though it is still on your hard drive.

After running the above command, be sure to add an entry to your .gitignore file so that ‘file’ doesn’t show up in 'git status' and that it can’t accidentally be re-added later.

from : http://www.gitguys.com/how-to-remove-a-file-from-git-source-control-but-not-delete-it/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值