Let us say you have one folder named target
under the root folder that you added into your .gitignore file. The folder structure is similar to the one below:
-project root
|- src
|-- your src files here
|- target
|- file1
|- file2
|-.gitignore
I assume you want to undo git ignore and selectively ignore file inside the directory that you added to ignore list earlier. Let's suppose you want to add file 1 only from the directory structure above onto git ignore. In this case, edit the .gitignore file to remove the /target/ folder pattern and add a new . gitignore inside the target folder with file1 as content. It should automatically pick up only file2 for tracking.
-project root
|- src
|-- your src files here
|- target
|- file1
|- file2
|- .gitignore - add file1 here
|-.gitignore - remove /target/ from here