git-移除某文件或文件夹的版本控制(ignore)
发布日期:2021-06-29 22:24:21 浏览次数:2 分类:技术文章

本文共 1079 字,大约阅读时间需要 3 分钟。

git-移除某文件夹的版本控制

git-移除某文件夹的版本控制,如我们把.idea目录误提达到远端。

有时候我们一开始在上传项目的时候把某些不必要的文件也添加进了git的版本控制。此时 gitignore 对这些文件就不起作用了。因此我们要先从 git 里面把这些文件 untracked ,然后修改 gitignore ,最后提交。

核心,使用git rm命令,添加参数 --cached

–cached 的意思是只去除版本控制而不删除本地文件,如果不写的话会把本地文件也删掉。所以要不要加 --cached 参数就看自己需要了。

具体步骤如下:

  1. git rm -r --cached 移除某文件夹的版本控制

    git rm -r -n --cached ".idea" //-n:加上这个参数,执行命令时,是不会删除任何文件,而是展示此命令要删除的文件列表预览。git rm -r --cached  ".idea"      //最终执行命令. git commit -m" remove .idea folder all file out of control"    //提交git push origin master   //提交到远程服务器
  2. 修改 .gitignore, 把对应的规则写入 .gitignore,让忽略真正生效;

    .gitignore添加 .idea

    .idea
  3. git push提交

工作常用举例

删除 .idea目录管理

git rm -r -n --cached ".idea" //-n:加上这个参数,执行命令时,是不会删除任何文件,而是展示此命令要删除的文件列表预览。git rm -r --cached  ".idea"      //最终执行命令. git commit -m" remove .idea folder all file out of control"    //提交git push origin master   //提交到远程服务器

删除cmake-build-debug-cygwin 目录管理

git rm -r -n --cached "cmake-build-debug-cygwin" git rm -r --cached  "cmake-build-debug-cygwin"  git commit -m" remove cmake-build-debug-cygwin folder all file out of control"git push origin master

转载地址:https://docker.blog.csdn.net/article/details/106143355 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:java socket-Socket端口复用(setReuseAddress)
下一篇:git-创建空分支

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月09日 09时41分53秒