How to ignore all files and folder of a folder, but not the folder itself?

Trying to ignore files and folder of a parent folder but want to upload the parent folder? Well, you are the right place ?. Let me show you how you can do that, the easiest way.

Let’s first create a folder. In Laravel, you will see resources folder. Add pending folder under resources folder. So the new folder location looks like this.


Now goto the pending folder by using following command.

cd resources/pending

It’s time to create a file called .gitignore under pending folder like this.

nano .gitignore

Basically, nano creates new file for you and makes ready to write content on it. After typing nano command you will see plan text editor. Within that plan editor, paste the following lines of texts.


Once you are done typing above texts, do as follows.

  1. Press control+x
  2. Type y and
  3. Press return or enter

You have successfully saved file. If you are not able to write, just add sudo text in front of nano .gitignore. It’s time to add to git and here are the steps to do it.

  1. Go to root direction where you commit your project. Use cd .. to go backward.
  2. git add .
  3. git commit -m "Added pending folder in resources folder."
  4. git push origin master

That’s all. You successfully added new folder and now all sub files and folders of pending folder will be ignored.

Hope this is helpful. Let me know if you need help. And don’t forget to share.

Thank you.

Leave a Reply