In this post I am sharing the command to remove files and folder from git repo.The command will remove files from the working tree and from the index.
Note: Before removing any files and directory it is always a good practice to keep the backup of the data.Hence suggesting to first take the backup of your data.
Follow the given below steps to remove file and directory from git repo
We assume you have already cloned the repository in your system from git server.Here for eg. we are giving the repository name as test-repo
Step 1: Change to Working repository in your system
Step 2: Here in this step, we will remove both file and directory
To remove the file from working tree and index,run the below command
git rm file-name
To remove directory,from working tree and index,run the below command
git rm -r dir-name
Note: If you want to remove all files and directory at a time,then change to directory and run below command. Here in below given command period(.) means from current location.
git rm -r .