Solution for git .gitignore failure

I recently wrote a vue project. Every time it is packaged and uploaded to the git repository, the dist file will also be uploaded . After the modification, I added a .gitignore file. (The file specified in the .gitignore file will not be is pushed to the git repository) but it is found that the dist will still be uploaded when uploading

Reason: there is a cache

First create a test warehouse, first check the status with git status , the workspace (the directory that can be seen in the computer) is clean

Add a readme.txt and check git status again, readme.txt has been modified so its status is Untracked. At this time, the local file is already cached

When you check git status again after git add . (add to staging area), the workspace is clean.

In fact, when something in the working directory is modified, it will be compared with the cache. When git status, the difference will be displayed. Therefore, in order to make the content in .gitignore effective, delete the staging area.

 

Solution

git rm -r --cached .        // Delete the local cache 

git add .                   // Submit the file to the staging area 

git commit -m 'Submission information'     // Submit code

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325274915&siteId=291194637