美文网首页
git排除已添加追踪的文件

git排除已添加追踪的文件

作者: 西贝_贾 | 来源:发表于2019-08-05 11:40 被阅读0次

Step 1: Commit all your changes

Before proceeding, make sure all your changes are committed, including your .gitignore file.

Step 2: Remove everything from the repository

To clear your repo, use:

git rm -r--cached .

rm is the remove command

-r will allow recursive removal

–cached will only remove files from the index. Your files will still be there.

The . indicates that all files will be untracked. You can untrack a specific file with git rm --cached foo.txt (thanks @amadeann).

The rm command can be unforgiving. If you wish to try what it does beforehand, add the -n or --dry-run flag to test things out.

Step 3: Re add everything

gitadd .

Step 4: Commit

gitcommit -m".gitignore fix"

Your repository is clean :)

Push the changes to your remote to see the changes effective there as well.

参考:http://www.codeblocq.com/2016/01/Untrack-files-already-added-to-git-repository-based-on-gitignore/

相关文章

  • git排除已添加追踪的文件

    Step 1: Commit all your changes Before proceeding, make s...

  • git 忽略&移除文件

    前言 在git仓库中,有时候需要添加某个文件并且追踪;有时候需要移除已经追踪的文件;或者不再追踪已经追踪的文件,但...

  • iOS开发之git学习

    /* 初始化git仓库:git init */ /* 添加文件到git仓库 */ 分两步: 第一步:追踪文件:gi...

  • 增加删除文件

    停止追踪文件 1 .git rm --cached [file] 添加每个变化前,都需要确认 1 .git add...

  • git 新建仓库 与远程关联

    1.新建本地仓库 git init 2.添加所有文件追踪 git add . 3.提交修改 git commit ...

  • Git---取消已追踪文件(rm --cached)

    首先:修改 .gitignore在 .gitignore 内排除需要追踪的目录/文件 第二步:执行git 命令删除...

  • Git命令备忘录

    1、git将文件添加到.gitignore文件中不生效? 原因:在加入.gitignore前该文件已经被追踪。gi...

  • 撤销git add操作

    使用Git的时候,有时候不小心使用git add,添加了不想追踪的文件。也就是track了一些不想track的文件...

  • .gitignore的使用

    .gitignore文件用于确保指定的文件不被git追踪,如果要停止追踪一个已经被追踪了的文件,可以使用git r...

  • Git常用命令

    git基本操作(1) 克隆:git clone + 远程仓库地址 查看未被追踪的文件:git status 追踪文...

网友评论

      本文标题:git排除已添加追踪的文件

      本文链接:https://www.haomeiwen.com/subject/mkgpdctx.html