How to handle deleted files in GIT

Git – Very useful and latest version control system. Now a days we use git for version control. Sometimes we stuck in error when we face following case

1) I have created new file and commited & pushed the changes to git by following command

  • git add /public_html/my/abc.php
  • git commit -m “my changes for fix”
  • git push origin master

By time, i don’t require abc.php file anymore.. I removed manually from server but what about to delete from git repo?

I have followed below steps to delete from repo

2) I deleted abc.php file manually from server, commands I followed

  • git rm /public_html/my/abc.php
  • git commit -m “my new fixes”
  • git push origin master

These are the steps to remove file from git repo

Make sure to take a back up first before run any command. Also need to take git pull to reflect the changes in other git copy

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.