skip to Main Content

Why on my git changes this files are added? I cannot find solution for this and reason. Also adding to .gitignore does not help. Thanks in advance for any tips on that!

enter image description here

I tried to add to .gitignore, update next, clear cache

    # Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
.next``

.next/
.next
.next/cache
.next/cache/images/XRLy2mj54hjpCmhHptAEqpb2WAUeGZGkZ7YPqY1zd7w=/60.1702714879042.Yhst-HY-v0t4UaR56ciP57mFAJtqv4BZZ5OqWkE94F8=.webp
*.js
.next/static/chunks/webpack.js

Each time i push commit and run the app the new changes (.next/cache/webpack are added to my git changes) even though i never touch this files

3

Answers


  1. Try to add to your gitignore:

    /.next/
    
    Login or Signup to reply.
  2. For Next.js, here is the recommended .gitignore file

    ### NextJS ###
    # dependencies
    /node_modules
    /.pnp
    .pnp.js
    
    # testing
    /coverage
    
    # next.js
    /.next/
    /out/
    
    # production
    /build
    
    # misc
    .DS_Store
    *.pem
    
    # debug
    npm-debug.log*
    yarn-debug.log*
    yarn-error.log*
    .pnpm-debug.log*
    
    # local env files
    .env*.local
    
    # vercel
    .vercel
    
    # typescript
    *.tsbuildinfo
    next-env.d.ts
    

    You can also stack multiple project type using some gitignore generator tool online, like this one

    Login or Signup to reply.
  3. I suspect that the folder was commited at some point and now it’s in the staging area. You first need to remove it from the staging area and then it will be ignored.

    Try this:

    • Be sure that you have on your .gitignore the folder .next or whatever you want to avoid commiting.
    • Run the following command to remove .next/ from the staging area: git rm -r --cached .next/
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search