Git Prune for Cleanup

When you or a team member removes a few branch from your remote git repository as part of cleanup and you still see the branches on your local environment you will have to run the git command below to remove (prune) all the branches from your local that do not exist on the remote repository anymore.

git fetch -p


If you ever committed a large file (over 50 MB) in your git repository and are having issues pushing to the repository, you will have to use the BFG tool to delete the large file not only from the latest commit but also from the history of all commits in your repository to work properly on github.

if you see a similar error when pushing :

Counting objects: 387, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (349/349), done.
Writing objects: 100% (387/387), 402.76 MiB | 7.53 MiB/s, done.
Total 387 (delta 108), reused 48 (delta 36)
remote: warning: File /xxxxxxxxxxmpg is 51.10 MB; this is larger than GitHub’s recommended maximum file size of 50.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage –
remote: error: Trace: d051ecdf77d64a9b66a168bcb9608b85
remote: error: See for more information.
remote: error: File docroot/sites/Black_Eyed_Peas_Concert.3gp is 334.19 MB; this exceeds GitHub’s file size limit of 100.00 MB
To [email protected]:xyxuhjhj.git
! [remote rejected] master -> master (pre-receive hook declined)

do the following after downloaidng the BFG tool: (Courtesy: BFG Tool)

git clone --mirror git://
java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git
$ cd some-big-repo.git
$ git reflog expire --expire=now --all && git gc --prune=now --aggressive