If you already have a .gitignore file with rules, you can change them.
My .gitignore looked like this;
#ignore these folders scripts/ lib/** logs/ # ignore these files .sql
Let's say you now want to include a file located at /lib/config.php. You would add this line;
#ignore these folders scripts/ lib/** logs/ # ignore these files .sql # allow !lib/config.php
git status and you should see ;
Now you can run
git add lib/
git status you should see;
new file: lib/config.php
Then add both files
git add .
From here you can commit and push to the remote repo.