Git Removing Files From Repository

October 15, 2011 | By Regaz.

Removing Unstaged Files

Removing a file that have Not already been Staged is as Simple as performing the Usual shell Command:

rm fileToDelete


Removing Files Git has already Taken into Account

Instead, if your files are already Staged or Commited and you Limit to Execute only the Default Shell Command after your file will continue to be Taken into Account from Git as “Changed but not updated.”
Instead, if you Remove it with the Git Command you will Remove Simultaneously and Permanently both from your Working Directory and from the Git Repo.
So this is the Right Way to Remove a File already Commited in a Git Repository:

git rm fileToDelete

But this is good only for a manual File Deletion, instead if you have Multiple Files that are already been Deleted without Git and are already Tracked inside the Staged Area. you need to Proceed with another command:

git add -u

This Command Automatically Remove from the Staged area all the Files that has already been Deleted.
Or you can provide to manual deletion of every Tracked File with a:

git rm path/To/yourFile

Latest if you Want Proceed to a Complete all-in-one Command that take into Account New Added and Removed Files you need to Use the -A Flag in add Command:

git add -A

If you want to Remove a File that has been already Staged you need to Take it Out from the Stage Area with:

git reset HEAD fileName

Next if you want also to delete it from Repository you follow like in Remove Unstaged Files.

Take a Look.

Bloogger Blogger, Google Blogger, Google Google

Bed and Breakfast in Asolo

QuickChic Theme • Powered by WordPress