Clean & Speed Up Your Local Git Repo With Three Commands

Sometimes ya gotta force push or rebase and leave some commits behind. On a large repo with many commits and remotes, your git commands could actually slow down with too many objects floating around. Consider running these commands to help keep things …


This content originally appeared on DEV Community and was authored by Ben Villalobos

Sometimes ya gotta force push or rebase and leave some commits behind. On a large repo with many commits and remotes, your git commands could actually slow down with too many objects floating around. Consider running these commands to help keep things in tip top shape.

git gc

Compresses and removes orphaned objects, thus speeding up commands in your local repo. Nice!
image

git fsck

Yes, I misread that too. git fsck shows you all orphan or dangling objects in your local repo. I cleaned up recently so mine isn't too bad.
image

git prune

If you don't plan on doing anything with the objects you saw using fsck, run git prune to clear them out. If you'd like to see what would be cleaned out without actually deleting them, run git prune -n for a dry-run.
image

In theory, cleanup happens somewhat regularly when running some of git's main commands. I haven't noticed, or is it just good at its job. In any case, I hope this helped!

I learned about these commands from the amazing Git Internals pdf. Every dev should read it.


This content originally appeared on DEV Community and was authored by Ben Villalobos


Print Share Comment Cite Upload Translate Updates
APA

Ben Villalobos | Sciencx (2021-04-20T08:27:37+00:00) Clean & Speed Up Your Local Git Repo With Three Commands. Retrieved from https://www.scien.cx/2021/04/20/clean-speed-up-your-local-git-repo-with-three-commands/

MLA
" » Clean & Speed Up Your Local Git Repo With Three Commands." Ben Villalobos | Sciencx - Tuesday April 20, 2021, https://www.scien.cx/2021/04/20/clean-speed-up-your-local-git-repo-with-three-commands/
HARVARD
Ben Villalobos | Sciencx Tuesday April 20, 2021 » Clean & Speed Up Your Local Git Repo With Three Commands., viewed ,<https://www.scien.cx/2021/04/20/clean-speed-up-your-local-git-repo-with-three-commands/>
VANCOUVER
Ben Villalobos | Sciencx - » Clean & Speed Up Your Local Git Repo With Three Commands. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/04/20/clean-speed-up-your-local-git-repo-with-three-commands/
CHICAGO
" » Clean & Speed Up Your Local Git Repo With Three Commands." Ben Villalobos | Sciencx - Accessed . https://www.scien.cx/2021/04/20/clean-speed-up-your-local-git-repo-with-three-commands/
IEEE
" » Clean & Speed Up Your Local Git Repo With Three Commands." Ben Villalobos | Sciencx [Online]. Available: https://www.scien.cx/2021/04/20/clean-speed-up-your-local-git-repo-with-three-commands/. [Accessed: ]
rf:citation
» Clean & Speed Up Your Local Git Repo With Three Commands | Ben Villalobos | Sciencx | https://www.scien.cx/2021/04/20/clean-speed-up-your-local-git-repo-with-three-commands/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.