1

I am developing a PhP application and using git to deploy it on heroku I am new to git

the project is almost about to terminate now my log folder shouldn't affect the server anymore I mean from now the log files should only saves the server status not my local branch, The structure is like this:

 MyProject
 |
  -logfolder/*

I put logfolder/* in the gitignore file but still the changes in my own logfolder are pushing alongside with other changes to server,..

what shall I do about it?

thanks in advance

imizeropt
  • 176
  • 1
  • 13
Siavosh
  • 2,314
  • 4
  • 26
  • 50

2 Answers2

1

You have to get this ADDED files out of the index by:

git rm -r --cached logfolder
git add logfolder
git commit -m "fixing .gitignore"
imizeropt
  • 176
  • 1
  • 13
  • It didn't work it removed the folder and it files from the server copy as well it doesn't exist anymore – Siavosh Feb 28 '14 at 15:24
  • Then back to the commit before this false advice. Sorry. But you have still to get them out of the index. – imizeropt Feb 28 '14 at 15:29
0

You should remove logfolder files from gits index and add a .gitignore file in logfile directory, The file contains the following.

# Ignore everything in this directory
*
# Except this file
!.gitignore

This link shows how to make empty directory. How can I add an empty directory to a Git repository?

And these command should fix your problem.

git rm --cached -r logfile
git add logfile/.gitignore

Then try to see everything is ok with, git status. And commit your changes.

You don't need to mention "logfile/*" in .gitignore root file.

Community
  • 1
  • 1
hossein
  • 313
  • 1
  • 8
  • I think You didn't get my question clearly, I don't need to make a folder empty my question is this: I have log folder that contains log files I uploaded the whole project on the server but I don't need the my local log files effect the server copy anymore, obviously because they are supposed to log the server. The git rm --cached -r logfolder will remove the directory in server as well – Siavosh Mar 01 '14 at 18:57
  • `git rm --chached -r logfolder` will not delete any file or folder it just removes them from git. – hossein Mar 02 '14 at 10:51
  • No you're right it doesn't delete anything from local copy but as soon as the next push to the server is committed the folder will be deleted from server copy – Siavosh Mar 02 '14 at 13:19