1

My project structure

drwxrwxr-x  7 jholmes jholmes 4096 дец 11 09:48 .
drwxr-xr-x 71 jholmes jholmes 4096 дец 22 18:08 ..
drwxrwxr-x 11 jholmes jholmes 4096 дец 10 11:54 backend
drwxrwxr-x  6 jholmes jholmes 4096 дец 22 18:08 frontend
drwxrwxr-x  8 jholmes jholmes 4096 дец 22 18:10 .git
-rw-rw-r--  1 jholmes jholmes  250 нов 25 12:25 .gitignore
drwxrwxr-x  4 jholmes jholmes 4096 дец 11 09:52 .history
-rw-rw-r--  1 jholmes jholmes   46 окт 27 11:35 README
drwxrwxr-x  2 jholmes jholmes 4096 дец  4 21:17 .vscode

I added .gitignore to my frontend

drwxrwxr-x   2 jholmes jholmes   4096 дец 15 16:39 components
-rw-rw-r--   1 jholmes jholmes    248 дец 22 17:48 config.js
-rw-rw-r--   1 jholmes jholmes    193 дец 22 18:08 .gitignore
drwxrwxr-x   5 jholmes jholmes   4096 дец 15 17:07 .next
-rw-rw-r--   1 jholmes jholmes    170 дец 22 17:44 next.config.js
drwxrwxr-x 452 jholmes jholmes  20480 дец 15 16:44 node_modules
-rw-rw-r--   1 jholmes jholmes    407 дец 15 16:44 package.json
-rw-rw-r--   1 jholmes jholmes 225100 дец 15 16:44 package-lock.json
drwxrwxr-x   2 jholmes jholmes   4096 дец 15 16:40 pages

When I push my repo to Github, I still have .next folder uploaded. This is my frontend

.gitignore

/node_modules

# testing
/coverage

# next.js
.next/
next.config.js

# production
/build

# misc
.DS_Store

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

How to deal with multiple folders?

phd
  • 82,685
  • 13
  • 120
  • 165
Richard Rublev
  • 7,718
  • 16
  • 77
  • 121

1 Answers1

1

It seems like the folders that were intended to be in .gitignore were already part of the git history, because they were committed before the addition of the .gitignore. A way to do it is to direct yourself into the folder, via cd path/to/folder and run git rm -r --cached . This removes the current directory from the history, and uncommit the files.

However, if you have committed the files before that, in the history it will still be reflected as a deletion. In the event what you're ignoring is potentially sensitive information, you should squash commits together to erase the traces.

Prashin Jeevaganth
  • 1,223
  • 1
  • 18
  • 42