markdown git Untrack文件已经基于.gitignore添加到git存储库中

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown git Untrack文件已经基于.gitignore添加到git存储库中相关的知识,希望对你有一定的参考价值。

## 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 <br />
> -r will allow recursive removal <br />
> –cached will only remove files from the index. Your files will still be there. <br />
> The . indicates that all files will be untracked. You can untrack a specific file with git rm --cached foo.txt (thanks @amadeann). <br />
> 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.<br />

## Step 3: Re add everything

```
git add .
```

## Step 4: Commit

```
git commit -m ".gitignore fix"
```

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

以上是关于markdown git Untrack文件已经基于.gitignore添加到git存储库中的主要内容,如果未能解决你的问题,请参考以下文章

Git 取消跟踪(untrack)

GitGit使用记录: 基于git ignore文件将remote上的文件untrack

markdown git rebase变基合并

使用git对vue项目进行版本控制

使用git对vue项目进行版本控制

git 小记