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:

node_modules
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.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay