How do I ignore a directory for pull?

1

I am presented with the following situation: I have a system that works with apache and php, I use style sheets in less, to simplify I have a folder structure like this:

rootDir/index.php
rootDir/img/
rootDir/css/
rootDir/less/
rootDir/js/

On the test server everything works best, when I make a change and it is ready I put it on the git server.
Now, when I want to do a pull from the production server to make those changes in the other environment I get all those files.
The problem is that the directory less no longer needed that these are compiled in css, but to pull these are brought anyway. I would like the structure of the production server to be like this

rootDir/index.php
rootDir/img/
rootDir/css/
rootDir/js/

I have tried so much to modify the .gitignore file on my production server to ignore the directory, which did not work, and also execute the git update-index --assume-unchanged less/* command, but when I execute the git update-index --refresh command it warns me that all less files need an update.
I can delete them manually whenever I pull, but I would like to avoid it if possible.


I edit my question to clarify the following:
It interests me that all the files are versioned, i.e. that the server git stores them and they are not ignored in a push, I only want that they are not in the production environment.

    
asked by Sacha 11.05.2018 в 22:40
source

2 answers

3

Short answer would be:

less/
  

Note that if you use only less you will ignore files called less, while if you use less/ you will ignore the directory as such.

Git does not ignore the files while you are shooting it. Instead, you must add these files to your .gitignore files, so that they are not committed and sent to remote repositories.

If these files are already in your remote repository, then you must delete them using, for example:

git rm --cached comun/main-local.php

git rm --cached comun/parametros-local.php

If you want to delete the common directory, then in .gitignore add:

comun/**

And delete the directory:

git rm --cached -r comun
  • Remove (rm).
  • Index (--cached).
  • Recursively (-r).

Now make a new commit and push . These files will be removed from the remote repository as well.

  

Here are some links that can help you too:

     
    
answered by 11.05.2018 / 23:03
source
2

One option is to specify in your file .gitignore (if you do not exist you can create it) the directory you want to be ignored, in this case the directory:

/less 

the .gitignore file must be located within:

rootDir/

Check the documentation about .gitignore .

Modify the .gitignore file in your local copy and upload it to the server.

    
answered by 11.05.2018 в 22:56