DEV Community

Cover image for Protecting your files on GitHub
Ubani Friday
Ubani Friday

Posted on

Protecting your files on GitHub

I made a tutorial on how to create a Simple Node.js Server which will serve as a basis for this tutorial as this tutorial will focus mainly on how to protect our files on GitHub.

Let's get started.
Adding protection to our files makes it safe from hackers on the web whose intentions are in a negative direction. To get rid of such people, there is need to protect our files on the local repository before pushing them to GitHub using Git.

To do this, we would need to add a file to the previous application whose GitHub link is provided above.

Adding .gitignore file

Create a file and name it ".gitignore" without the quote.
Open the file.
Enter the name of the file you want to save.

See sample code and image below:

Enter fullscreen mode Exit fullscreen mode

Image description

.gitignore is a directory that hides whatever file that is placed in it. Here we will hide the node_modules file from the viewers so as to reduce the size of our app when pushed to GitHub. By doing so, the file(node_modules) will no longer be visible to viewers who try to access the public repository on GitHub.

When all is done you can now push your local repository to GitHub.

Image description

From the sample image above you will notice that the node_modules directory on your local repository is no longer on remote repository.

Get the sample code on GitHub.

I look forward to hearing from you by leaving a message on the comment tag.
Drop a like if this tutorial was helpful and follow me to get all my tutorials.

Thanks for reading.

Top comments (0)