Last Updated: February 25, 2016
·
751
· bm2yogi

Clean up your local git repo

Where I work, it's pretty common to switch between projects, and often enough, a project will have changed somewhat since the last time I was in there. So that means I need to sync my local repo with the remote before I create my feature branch. I want to make sure I'm getting a good clean build and I don't have any old artifacts lying around, gumming up the works.

So, I make sure to clean out unneeded files and reset my branch to a good state. I found myself doing this often enough that I created an alias in my .gitconfig to do this for me.

[alias]
    nuke = !git clean -fdx & git reset head --hard & git pull

So now from the project root I type:

git nuke

And I'm assured that what I've got locally is exaclty what's in the remote repo, and I can create my feature branch and get to work.

HTH,

Mike