I have a tmp directory in my git repo I\'d like to still exist, but be ignored. I added it to .gitignore
, but git status
still tells me about chan
It sounds like you are trying to track a file (e.g. index.php
), add it to a remote repository, then stop watching tracking it, while keeping the file in the remote (i.e. keep index.php
unchanged on the remote repo while changing it locally).
From what I understand, git cannot do this. You can either track a file, or not. If you track a file, it exists in the remote repo, and changes when you commit changes to it. If you don't track a file, it doesn't exist in the remote repo.
Because it is not possible to do exactly what you want with git, there are potentially other solutions, depending on your exact situation. For example, why do you not want index.php
to change on remote when you change it locally? Are there user-specific settings in the file? If this is the case, you can do:
cp index.php index_template.php
git rm --cached index.php
Now edit index_template.php to be as you want it to appear on the remote repo. Add something to your README to tell the people using your repository that once they clone it, they must copy index_template.php to index.php and edit it to suit their needs.
git add index_template.php
git add README
git commit -m 'added template index.php file'
git push
When someone clones your repo, they must create their own index.php
. You've made it easy for them: simply copy index_template.php
to index.php
and revise it with computer-specific settings.