2

How to gitignore a file when committed to remote repository

 2 years ago
source link: https://dev.to/mhasan/how-to-gitignore-a-file-when-committed-to-remote-repository-212c
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to gitignore a file when committed to remote repository

Sometimes as a new programmer or developer we pushed our local committed files to remoted repository. So, as a new programmer or developer need to understand which files should commit and which shouldn't committed.

for security and others issues we shouldn't commit and push such files and folders (directories) like noude_modules, .env, npm packages, yarn.lock and many more depend on which project and development you're work on.

Suppose, if you mistakenly committed and push a file that you get warn from GitHub or GitLab or have security vulnerable that should remove at any possible way.

Then the git command you need to apply is: git rm -r --cached

By this command you can remove your desired file from the commit and when you git add ., git commit and git push then you can able to remove that file from remote repository.

You can add these file to gitignore, so that these file will never commit and push to remote repository.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK