.gitignore ignore file does not take effect

foreword

  • When .gitignore ignores files, it is a very important configuration for git warehouses. When creating warehouses, there will be template selection and ignored files.

  • .gitignore ignores files means that when uploading to the code warehouse, control which code files are not uploaded to the code warehouse.

  • In the actual development, the code written is not very big, the main thing is that the plug-in local pictures and third-party packages occupy the space.

  • According to the requirements, we can ignore node_model, dist, package-lock.js (the home page article), and other related files.

.gitignore ignore file syntax specification and meaning

  • #Comments start with

  • to *match zero or more characters

  • to ?match a single character

  • to []match any character within the brackets

  • !Indicates not to ignore (track) matched files or directories

  • Do not add any symbols to ignore this file in the current directory directly

  • /Beginning with ignores files in the current directory, but does not include files in subdirectories

  • /Ignore all files and content in the directory ending with , whether it is the root directory or subdirectory will be ignored

Vue projects generally default to .gitignore to ignore file configuration -vue-admin

.DS_Store
node_modules/
dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
**/*.log
​
tests/**/coverage/
tests/e2e/reports
selenium-debug.log
​
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.local
​
package-lock.json
yarn.lock
 
 

.gitignore ignore file scenario

1. When creating a warehouse, select .gitignore to ignore the file. When submitting the code for the first time to synchronize the code, set the .gitignore to ignore the file to take effect.

2. After synchronizing the code, forget to set .gitignore to ignore the file. After development, set it and push it to the warehouse --.gitignore ignores the file and does not take effect

3. The warehouse did not select the .gitignore ignore file, and developed the creation of a .gitignore ignore file to configure the push warehouse--.gitignore ignore file does not take effect

.gitignore ignores the reason why the file does not take effect

When we synchronize the code for the first time after we configure the basic framework, we configure .gitignore to ignore the file to take effect. It is used to just git init. These files have not been modified after connecting to the remote warehouse. In the case of 2.3, we git init with The remote warehouse is connected, and after development, these files will be modified, and git will track these files, which can be understood as a cache. These files are being tracked, so naturally they cannot be ignored

Check if the file is tracked --git status

 

Solve the problem that .gitignore ignores the file does not take effect -- clear the local cache (change to untracked state)

git rm -r --cached
git add .
git commit -m 'update .gitignore'
git push -u origin master

Summarize:

After this process, I believe you also have a preliminary deep impression on the fact that . Its case. Come on, hit the workers!

Please point out any deficiencies, thank you -- Fengguowuhen

Guess you like

Origin blog.csdn.net/weixin_53579656/article/details/131116599