How to delete files permanently from your local and remote git repositories
BY Anoop John
5 years ago
comments comment

If you frequently have to set up git version control system for existing projects then you would very likely run into the problem of having to remove files, which should not have been in git, from git after they were added. Running a git rm will only delete the file from the head and the file would still remain in the repository. This may be alright for small files but this could be troublesome for large files as these would unnecessarily bloat the git repository. But don't worry git being a 'swiss army knife' of version control systems there is a solution to delete files permanently from both your local and remote git repositories.

Do note that this is not a newbie solution and you have to do your bit of reading up on these commands and their implications before you actually run this on a production repository. Also note that you have to have RW+ permissions on the repository to do non-fast-forward pushes

CD to your local working folder and run the following command

git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch FOLDERNAME" -- --all

replace FOLDERNAME with the file or folder you wish to remove from the given git repository.

Once this is done run the following commands to clean up the local repository

rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now

Now push all the changes to the remote repository

git push --all --force

This would clean up the remote repository.

Now you will have to recreate the .git folders of all the working copies of the repository. This would include cloned repositories by other developers or the cloned repositories at the live and dev sites. You can do this by cloning the repository afresh into a temporary folder and the move the .git folder from the newly cloned repository to the local repository after deleting the existing .git folder from in there. Do remember to checkout the same branch as is already checked out in the local repository in the temporary repository before you move the .git folder to the local repository.

Remember to make a backup copy of the latest repository and the latest local files before you do any of these things so that you can fall back to a working repository if you run into issues.

Do this if you are confident of your git capabilities or else call up the experts :-). Let us know and we will be happy to offer our offshore Drupal development services to help you maintain your server and your repositories.



on 07th May 2007 / by webmaster
If your blog supports UTF-8 encoding then it is very easy to write and comment in Malayalam in yo Malayalam Open Source Free Software Leave a reply Your email address will not be published. Required fields are marker * V (not verified) access_time 18 Aug 2019 - 14:33 Check out Scripto - Allows you to type in malayalam and post directly to blogs. ITGalary Forum (not verified) access_time 18 Aug 2019 - 14:33 Really helpfull. I am planning to integrate it to my site. suraj (not verified) access_time 18 Aug 2019 - 14:33 send to me malayalam writing software webmaster access_time 18 Aug 2019 - 14:33 In reply to malayalam writing software by suraj (not verified) You can follow the instructions in the article to enable writing and reading in malayalam Add new comment

on 04th October 2007 / by webmaster
A new software developed by Zyxware Technologies all about to revolutionize the way information is collected and processed in tracking diseases like Chikungunya, Dengue, Malaria. The software, is being dedicated to the nation as Free Software under the GNU General Public License (GPL) on 5th October 2007. The first copy of the software will be handed over to the Hon'ble Minister for Health Smt. P. K. Sreemathi Teacher in a function to be held at the minister's office. Announcements Open Source Press Releases Web Development Free Software Leave a reply Your email address will not be published. Required fields are marker * Subhash Krisha… (not verified) access_time 18 Aug 2019 - 14:27 I express my appreciation for exceptional work done by you and your team. The objectives in releasing the software as Free and Open Source Software will definitely be an inspiration to millions of Youth who aspire to see our Great India a developed country by 2020. I hope this will inspire youngsters to take bold steps in trying out their ideas and contributing it to our country, however small their contributions may be. I send my warm regards and wish you continued success. Subhash Krishanamoorthy Resmi G (not verified) access_time 18 Aug 2019 - 14:27 My Hearty congrats to zyxware team!!!! Hope this software will go a long way in tackling epidemics like chikungunya. It will be a boon to milliions of people like me who are suffering from chikungunya. The main hurdle at the clinical level for epidemics like chikungunya is that no medicines have been identified for treating this disease. Doctors just prescribe pain killers and paracetamol. The need of the hour is a sincere effort at the govt level to do extensive research for the roots of this disease , develop preventives and prevent such outbreaks in future. Such efforts aided with a GIS software like zyxwares’s will go a long way in eradicating these epidemics. Jai (not verified) access_time 18 Aug 2019 - 14:27 Kudos. I appreciate the effort and contribution from the Zyxware Technologies Team. I hope it would be possible to import the data (both demographic & clinical) collected through Electronic Medical Records (EMR’s) and Hospital Information Systems (HIS) database into the above mentioned modules (Health Monitoring System Management Console and Health Monitor GIS/Reporting Interface application), to generate disease patterns/trends, analyse reasons for occurrance, predict possiblity for future outbreaks for prevention etc. Such a feature/effort could help acheive better results in public health administration in India and other developing countries. Best Wishes Jai Sri Sathya Sai Information Technology Centre Prasanthi Nilayam Sukhdev Singh (not verified) access_time 18 Aug 2019 - 14:27 Please announce the URL from which this Open Source software can be downloaded. Brig K S Kali Prasad (not verified) access_time 18 Aug 2019 - 14:27 A very good effort and well organized GIS Information using the OGC to be studied for all cost effective projects Pagination Current page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Next page Next › Last page Last » Add new comment
Leave a reply
Your email address will not be published. Required fields are marker *

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
The content of this field is kept private and will not be shown publicly.
CAPTCHA This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Bruce Edge (not verified)
access_time 18 Aug 2019 - 14:33

Should you not also use "--tag-name-filter cat " as well?

Using the above command, I get may warnings like:
WARNING: You said to rewrite tagged commits, but not the corresponding tag.
WARNING: Perhaps use '--tag-name-filter cat' to rewrite the tag.