To untrack a file or directory from your Git repository without deleting it physically follow the following steps. The example should work on any operating system as long as you have access to is terminal window or command prompt in order to enter the commands.
- Open the Terminal Window (Linux) or Command Prompt / Powershell (Windows)
- Move inside your working directory
- To untrack a file, type in the following command in the terminal and hit <Enter>$ git rm –cached <file-name>
- To untrack a directory, type in the folowing command in the termal and hit <Enter>$ git rm –cached -r <directory-name>