Skip to content

Instantly share code, notes, and snippets.

@gajoseph
Last active May 30, 2018 18:25
Show Gist options
  • Save gajoseph/8c9f1fc13ceef268ef8ec793a2de4d42 to your computer and use it in GitHub Desktop.
Save gajoseph/8c9f1fc13ceef268ef8ec793a2de4d42 to your computer and use it in GitHub Desktop.
safely delete a file from git repository,
### GIt prem delete a file
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch FOLDERNAME" -- --all
rm -rf .git/refs/original/
### prune entries older than the specified time
git reflog expire --expire=now --all
### Cleanup unnecessary files and optimize the local repository; prune object older than now
git gc --prune=now
###
git gc --aggressive --prune=now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment