Reputation: 31337
As I've been told, git doesn't recognize folders de per se. In order to have the folder to be on the repo, but not the files inside we did create a .gitignore file inside that folder with the following inside:
# Ignore everything in this directory
*
# Except this file
!.gitignore
It happens however that, inside that directory, we now need to add a new file that SHOULD be tracked by the git.
How can we proceed ?
Should we, do the steps on the following order ?
Change to:
# Ignore everything in this directory
*
# Except this file
!.gitignore
!mynewfile.php
git add mynewfile.php
git commit -a -m "added new file inside specific folder"
git push
(so that my remote hub knows about this and syncs with master so that all stay equal).
Or, should we proceed differently ?
Upvotes: 1
Views: 245
Reputation: 90336
The steps you suggest are OK, but step 1) is unneeded as there's no need to change your .gitignore
file, just add it with --force
flag and commit it.
Listing files in .gitignore
tell git that they are meant to be untracked, but it doesn't prevent you to track them. It applies only to untracked files, there's nothing wrong into having tracked files listed in it.
Upvotes: 1