How did I do?*

Remove tracked files from source control

Introduction

I've come across a few repositories in the past when working alongside smaller teams where everything has been source controlled, including things like build output and packages like node_modules, whether intentionally or not, this isn't good practice, and you need to be able to tidy up the repository by removing these files, and preventing changes to the files locally from being tracked as changed.

Git forget and ignore

Running the following command removes the specified files and directories (recursively) from source control tracking. These files will then be shown as changes/additions to the repository in your IDE or terminal.

git rm -r --cached <file/directory>

 

The next step is to add the applicable absolute or wildcard paths and filenames of these files and directories to the repository's .gitignore file, then committing your changes.